#๐Ÿ”’ Connectivity issue

43 messages ยท Page 1 of 1 (latest)

fathom isle
#

Python shell gets restarted everytime I run this code, it is not getting connected with MySQL

import mysql.connector as msc
try:
a = msc.connect(host="localhost",user="root",password="",database="bro")
c = a.cursor()
c.execute("select * from bruh")
a.commit()
print("Executed successfully")
except Exception as e:
print(f"An error occurred: {e}")

blissful zealotBOT
#

@fathom isle

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

grizzled beacon
#

!traceback
Remove the try/except. Print out the entire traceback.

blissful zealotBOT
#
Traceback

Please provide the full traceback for your exception in order to help us identify your issue.
While the last line of the error message tells us what kind of error you got,
the full traceback will tell us which line, and other critical information to solve your problem.
Please avoid screenshots so we can copy and paste parts of the message.

A full traceback could look like:

Traceback (most recent call last):
  File "my_file.py", line 5, in <module>
    add_three("6")
  File "my_file.py", line 2, in add_three
    a = num + 3
        ~~~~^~~
TypeError: can only concatenate str (not "int") to str

If the traceback is long, use our pastebin.

fathom isle
#

I am not getting any error tho

#

Not even an exception

#

If if I remove the try/except block, it's still the same case

grizzled beacon
#

So completely silent? No output at all?

fathom isle
#

Yes

#

It shows Restart : Shell

split plank
#

What are yiou using to run this file?

fathom isle
#

Python IDLE

#

So what's the issue?
Not knowing how to resolve this, I even uninstalled both MySQL and Python, deleted all files, reinstalled both and the connector through command prompt
Nothing changed

#

Got a project to do with 700 line code like this ๐Ÿ˜ฆ

split plank
#

700 lines? you only showed like 10

fathom isle
#

This is an example code to show the error

split plank
#

I can't find anything on google about what could cause this

fathom isle
#

The 700 line code is a Timetable Generator code

#

Me neither

split plank
#

can you try running the file through the terminal instead?

fathom isle
#

That's why I installed discord XD

#

Dk how to use terminal

split plank
#

go to the folder your python file is in

#

right click -> open in terminal

fathom isle
#

Oh you mean the black interface, just like the command prompt?

split plank
#

yes the command prompt

fathom isle
#

What do I do there?
Type in the same code?

split plank
#

when you are in the folder your python code is in run the command py please.py

fathom isle
#

It still got restarted

split plank
#

with what message

fathom isle
#

That 2nd connecting statement is causing this

#

That's where it all stops

#

Idk why

split plank
#

and you are using mysql-connector-python (not mysql-connector)

fathom isle
#

Yes

split plank
#

I don't know why it would crash without even an error message

fathom isle
#

Ikr

#

No solution? ๐Ÿ˜ฆ
I don't wanna uninstall and reinstall again

#

Anyone?

blissful zealotBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.