PyMySQL Traceback Error

279 views
Skip to first unread message

Alex

unread,
Jan 28, 2019, 12:04:26 AM1/28/19
to PyMySQL Users
Can anyone help me with this? 




import pymysql.cursors

# Connect to the database
connection = pymysql.connect(host='ip-hidden',
                             user='username-hidden',
                             password='password-removed',
                             db='db-name-hidden',
                             charset='utf8mb4',
                             cursorclass=pymysql.cursors.DictCursor)

try:
   
with connection.cursor() as cursor:
       
# Create a new record
        sql = "INSERT INTO `Students` (`StudentID`, `Name`, 'Sun1', 'Mon1', 'Tue1', 'Wed1', 'Thu1', 'Sun2', 'Mon2', 'Tue2', 'Wed2', 'Thu2') VALUES (%s, %s)"
        cursor.execute(sql, ('3915145476', 'Alex Panagis', 1, 1, 1, 0, 0, 1, 0, 1, 1, 1))

   
# connection is not autocommit by default. So you must commit to save
    # your changes.
    connection.commit()
   
with connection.cursor() as cursor:

       
# Read a single record
        sql = "SELECT `StudentID`, `Name` FROM `Students` WHERE `StudentID`=%s"
        cursor.execute(sql, ('3915145476',))
        result
= cursor.fetchone()
       
print(result)
finally:
    connection
.close()

How come it returns the following error?

Traceback (most recent call last):
  File "/Users/alexjpanagis/Desktop/NEA/python-registration/sqltest.py", line 10, in <module>
    cursorclass=pymysql.cursors.DictCursor)
  File "/Users/alexjpanagis/Desktop/NEA/python-registration/venv/lib/python3.6/site-packages/pymysql/__init__.py", line 94, in Connect
    return Connection(*args, **kwargs)
  File "/Users/alexjpanagis/Desktop/NEA/python-registration/venv/lib/python3.6/site-packages/pymysql/connections.py", line 325, in __init__
    self.connect()
  File "/Users/alexjpanagis/Desktop/NEA/python-registration/venv/lib/python3.6/site-packages/pymysql/connections.py", line 599, in connect
    self._request_authentication()
  File "/Users/alexjpanagis/Desktop/NEA/python-registration/venv/lib/python3.6/site-packages/pymysql/connections.py", line 861, in _request_authentication
    auth_packet = self._read_packet()
  File "/Users/alexjpanagis/Desktop/NEA/python-registration/venv/lib/python3.6/site-packages/pymysql/connections.py", line 684, in _read_packet
    packet.check_error()
  File "/Users/alexjpanagis/Desktop/NEA/python-registration/venv/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/Users/alexjpanagis/Desktop/NEA/python-registration/venv/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user 'admin'@'188.135.12.231' (using password: YES)")

Process finished with exit code 1

Kasmadi

unread,
Jan 28, 2019, 3:19:44 AM1/28/19
to pymysq...@googlegroups.com
cek your db password 

--
You received this message because you are subscribed to the Google Groups "PyMySQL Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pymysql-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

INADA Naoki

unread,
Jan 28, 2019, 3:51:57 AM1/28/19
to pymysq...@googlegroups.com
He double posted this to MySQL slack, and I respond there already.
> --
> You received this message because you are subscribed to the Google Groups "PyMySQL Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pymysql-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
INADA Naoki <songof...@gmail.com>
Reply all
Reply to author
Forward
0 new messages