0
$\begingroup$

I got this positional argument error. Here is the code that I copy from other sources.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [15], in <cell line: 3>()
      1 ############### CONFIGURE THIS ###################
      2 # Open database connection
----> 3 db = pymysql.connect("localhost","sql8510682","6huzgCC7q3","sql8510682")

TypeError: __init__() takes 1 positional argument but 5 were given
$\endgroup$

1 Answer 1

0
$\begingroup$

Try naming arguments, from the documentation, it should work (of course, adapt your values):

import pymysql

# Connect to the database
connection = pymysql.connect(host='localhost',
                             user='user',
                             password='passwd',
                             database='db',
                             charset='utf8mb4',
                             cursorclass=pymysql.cursors.DictCursor)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.