[Python] I'm having serious issues with simple pymysql initialization with my localhost sql...

Discussão em 'Python' iniciado por Stack, Novembro 30, 2025.

  1. Stack

    Stack Membro Participativo

    Some time ago I had tried to install MySQL workbench correctly on my system, and it was a tremendous headache. This is because I use Kubuntu with a very new version of Ubuntu Release, and I had a lot of problems. At some point (I don't know which one exactly) I must have done something that totally complicated my MySQL. I had to reinstall it again due to these problems, I reinstalled my MySQL and I can currently log into it smoothly through the CLI. My MySQL runs on:

    tcp6 0 0 :::33060 :::* LISTEN -


    I've had numerous problems with simply booting my MySQL into PyMySQL. I'm starting to lose my mind, it's just frustrating. Every time I manage to resolve an exception, another one arises again. Like I'm in an endless loop of bad luck

    My problem is specifically with pymysql.connect. First I tried to initialize with positional arguments:

    conexao = pymysql.connect("localhost", 'root', '(pass)', 'sistema', 33060)


    And my mistake was always:

    Traceback (most recent call last):
    File "/home/user/Documentos/SellBot/db.py", line 3, in <module>
    conexao = pymysql.connect("localhost", 'root', '(pass)', 'sistema', 33060)
    TypeError: Connection.__init__() takes 1 positional argument but 6 were given


    After this I saw some users who had the same problem and I performed the solution they had given:

    conexao = pymysql.connect(host="localhost", user='root', password='(pass)', database='sistema', port=33060)


    And to my misfortune, my problem now was about the connection class:

    Traceback (most recent call last):
    File "/home/user/Documentos/SellBot/db.py", line 3, in <module>
    conexao = pymysql.connect(host="localhost", user='root', password='(pass)', database='sistema', port=33060)
    File "/home/user/Documentos/SellBot/venv/lib/python3.13/site-packages/pymysql/connections.py", line 365, in __init__
    self.connect()
    ~~~~~~~~~~~~^^
    File "/home/user/Documentos/SellBot/venv/lib/python3.13/site-packages/pymysql/connections.py", line 680, in connect
    self._get_server_information()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
    File "/home/user/Documentos/SellBot/venv/lib/python3.13/site-packages/pymysql/connections.py", line 1109, in _get_server_information
    self.server_thread_id = struct.unpack("<I", data[i : i + 4])
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
    struct.error: unpack requires a buffer of 4 bytes


    I don't really know what else I can do, I need some help. Thank you in advance

    My Python version: Python 3.13.3
    My PyMySQL version: PyMySQL==1.1.2
    OS: Kubuntu x86_64

    Continue reading...

Compartilhe esta Página