mysql-connector-python

Docker Alpine build fails on mysqlclient installation with error: Exception: Can not find valid pkg-config name

Docker Alpine build fails on mysqlclient installation with error: Exception: Can not find valid pkg-config name Question: I’m encountering a problem when building a Docker image using a Python-based Dockerfile. I’m trying to use the mysqlclient library (version 2.2.0) and Django (version 4.2.2). Here is my Dockerfile: FROM python:3.11-alpine WORKDIR /usr/src/app COPY requirements.txt . RUN …

Total answers: 7

Why does MySQL return error on creating a table?

Why does MySQL return error on creating a table? Question: I’ve been trying to create a table with user input name but I get an error no matter how I write the query. right now query is like this: query=("CREATE TABLE "+t+" ( NAME VARCHAR , DISTANCE VARCHAR , PRICE VARCHAR , LOCATION VARCHAR)") and …

Total answers: 1

Accelerating slow MySQL import using python connector

Accelerating slow MySQL import using python connector Question: I’m writing a python script which imports a large database into MySQL. So far I used this approach, and it works, but it is slow: importdb = "mysql -h " + DB_HOST + " -u " + DB_USER + " -p" + shlex.quote(DB_USER_PASSWORD) + " " + …

Total answers: 1

'DatabaseError' is not being caught by mysql.connector.errors.DatabaseError python

'DatabaseError' is not being caught by mysql.connector.errors.DatabaseError python Question: I am using SQLAlchemy and mysql-connector. While executing a query, if I get mysql.connector.errors.DatabaseError I have used the exception provided by mysql. The exception is going in the Exception block and not in the DatabaseError catch block. Code try: row_exists = None session_object = self.connect_to_database() # …

Total answers: 1

Querying data with common words using python connector — avoid code duplication

Querying data with common words using python connector — avoid code duplication Question: I am new to SQL and relatively new to python. I’m trying to fetch some information from the database using mysql.connector. And I found myself copying and pasting a lot. I tried using LIKE so that I could just execute once and …

Total answers: 1

i cant use python input to create mysql database

i cant use python input to create mysql database Question: I want to take input from user of creating a mysql database I cant use python input to create mysql databasewhat i tryed Getting this error please help the error Asked By: NAKULOP1 || Source Answers: execute() method parameters must be provided as a tuple, …

Total answers: 2

mysql.connector.errors.NotSupportedError: Authentication plugin 'mysql_native_password' is not supported only with pyinstaller exe

mysql.connector.errors.NotSupportedError: Authentication plugin 'mysql_native_password' is not supported only with pyinstaller exe Question: I am fighting to find a solution for my problem: When I start my Python application in my IDE, the database connection is working fine. But when I build an exe with pyinstaller with the following command python3 -m PyInstaller .home.py and start …

Total answers: 3

Character set 'utf8' unsupported in python mysql connector

Character set 'utf8' unsupported in python mysql connector Question: I’m trying to connect my database to a python project using the MySQL connector. However, when using the code below, import mysql.connector mydb = mysql.connector.MySQLConnection( host="localhost", user="veensew", password="%T5687j5IiYe" ) print(mydb) I encounter the following error: mysql.connector.errors.ProgrammingError: Character set ‘utf8’ unsupported I tried to find out why …

Total answers: 5

MySQL-Python Wont create the table

MySQL-Python Wont create the table Question: I am trying to create a few tables using Python, the first few worked and this specific one not. This is my code: sql = "CREATE TABLE citizens( ID INT PRIMARY KEY AUTO_INCREMENT, full_name VARCHAR(100), age INT, Gender ENUM(‘F’, ‘M’), cultivation VARCHAR(100), rank INT, isRouge ENUM(‘Yes’, ‘No’), sect_id INT)" …

Total answers: 3