1

There is a question called : Python best practice and securest to connect to MySQL and execute queries an there Mr. Kirk Strauser says:

You can see which your client library supports by looking at the paramstyle module-level variable:

>>> clientlibrary.paramstyle
'pyformat'

But when I run this on my python 3 I get :

>>> clientlibrary.paramstyle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'clientlibrary' is not defined

I also searched in pip

pip3 search clientlibrary
<nothing>

what can I do ?

Pedram Parsian
  • 3,750
  • 3
  • 19
  • 34

1 Answers1

1

The paramstyle is required for any python database module (see PEP-249, the clientlibrary is just a placeholder for the datbase module you're using.

E.g.

>>> import mysql.connector as clientlibrary
>>> clientlibrary.paramstyle
'pyformat
>>> import mariadb as clientlibrary
>>> clientlibrary.paramstyle
'qmark 
Georg Richter
  • 5,970
  • 2
  • 9
  • 15
  • when I try to do this I got : `>>> import mariadb as clientlibrary Traceback (most recent call last): File "", line 1, in ImportError: No module named 'mariadb' ` – donthitmyface Dec 11 '19 at 18:49
  • but it worked with `import mysql.connector as clientlibrary` – donthitmyface Dec 11 '19 at 18:52
  • Since you didn't install the database modules. Maybe mariadb is not a good example, since it's not available yet via PyPi and still alpha. But these modules were already installed on my machine. – Georg Richter Dec 11 '19 at 18:54