I am new to all this stuff
I am trying to access my website database (phpmyadmin) from python. All the tutorials available on internet are using xampp localhost which is perfectly working but When I replace localhost with my website address or host ip at it gives error ([Errno 11001] getaddrinfo failed)
import pymysql
db = pymysql.connect(host='localhost', user='root',passwd='')
cursor = db.cursor()
query = ("SHOW DATABASES")
cursor.execute(query)
for r in cursor:
print(r)
OUTPUT
('indus',)
('information_schema',)
('mysql',)
('performance_schema',)
('phpmyadmin',)
('test',)
('wordpress',)
replacing localhost with website address or domain ip gives output
Traceback (most recent call last):
File "C:\Users\HYSTOU\PycharmProjects\HelloWorld\venv\lib\site-packages\pymysql\connections.py", line 613, in connect
sock = socket.create_connection(
File "C:\Users\HYSTOU\AppData\Local\Programs\Python\Python39\lib\socket.py", line 823, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Users\HYSTOU\AppData\Local\Programs\Python\Python39\lib\socket.py", line 954, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\HYSTOU\PycharmProjects\HelloWorld\indusExtractingFloat.py", line 26, in <module>
db = pymysql.connect(host='https://www.rubick.org/', user='root',passwd='')
File "C:\Users\HYSTOU\PycharmProjects\HelloWorld\venv\lib\site-packages\pymysql\connections.py", line 353, in __init__
self.connect()
File "C:\Users\HYSTOU\PycharmProjects\HelloWorld\venv\lib\site-packages\pymysql\connections.py", line 664, in connect
raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'https://www.rubick.org/' ([Errno 11001] getaddrinfo failed)")
Using other methods gives (Times out)