Questions tagged [mysql-python]

Use this tag for questions about the MySQL-Python database connector library (MySQLdb). Do not use this tag for questions about MySQL Connector/Python (use the [mysql-connector-python] tag instead).

Filter by
Sorted by
Tagged with
2 votes
1 answer
24 views

cursor.fetchall() function return an empty list - python mysql

I tried to query some data from mysql database, but i couldn't fetch any data even though the data is indeed exist in the database and there is no error message whatsoever. mysql_config={ 'user' : ...
Satria Muhammad Saglan's user avatar
-1 votes
0 answers
21 views

can we use if statements within union_all in mysql

is possible to use if statements within unionall in mysql? SELECT ID, ORDER_NUMBER FROM OB_ORDER UNION ALL IF 1<>1 THEN SELECT ID, ORDER_NUMBER FROM OB_ORDER; END IF; UNION ALL SELECT ID, ...
Moule's user avatar
  • 1
0 votes
0 answers
22 views

ModuleNotFoundError: No module named 'MySQLdb' in macOS 13.4

when I start the python application in macOS 13.4 with M1 chip, shows error like this: Traceback (most recent call last): File "<frozen importlib._bootstrap>", line 1027, in ...
Dolphin's user avatar
  • 31k
0 votes
0 answers
10 views

I'm having a problem populating a flask wtform stringfield with data from a FK related mysl table

These are the related tables: tables I have managed to populate the stringfield, with some help from another question here, but the problem is that the dropdown only displays the second row twice when ...
maxjames's user avatar
-1 votes
1 answer
241 views

No module name pwd

**I am trying to connect Mysql to Django ** DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'djsql', 'USER':'root', 'PASSWORD' : 'root', ...
Sujata R's user avatar
  • 189
0 votes
0 answers
23 views

Flask for loop returns correct records but no content

The following Flask code returns correct number of records, including the corerct data in the terminal: @app.route('/Contacts/', methods = ['GET']) def contacts_overview(): cursor = db.cursor() ...
Dogra's user avatar
  • 1
0 votes
0 answers
45 views

After calling the function from within it self the previous values remain

I created a function called block_unblocked which just changes a value from a mysql column called ABlocked. I wanted it to not accpect inputs with spaces in 'user' so I decided to call the function ...
Riku's user avatar
  • 23
0 votes
0 answers
21 views

I'm trying to make a project using Python MySQL and Python Flash but its not updating the database [duplicate]

So Using Flask_Wtf I'm trying to insert that data into a MYSQL database but it doesn't do anything like the attempt didn't happen. it MYSQL workbench thinks that nothing is there but i know the ...
Joebace's user avatar
0 votes
1 answer
167 views

How to install mysqlclient in a python:3-slim Docker image without bloating the image?

I'm using python:3-slim Docker image and want to use the mysqlclient package from Pypi but getting the following error from RUN pip install mysqlclient command: ... Collecting mysqlclient ...
Alastair McCormack's user avatar
1 vote
1 answer
49 views

I'm having problems trying to insert a varying number of values in a column, python-sql

Im new to sql, I have been trying to make a function that will allow creation of new columns and to fill it. Its been giving these two errors: Failed executing the operation; Not all parameters were ...
Riku's user avatar
  • 23
0 votes
0 answers
24 views

Unable to Conneqt Mysql server to jupyter notebook due to InterfaceError: (mysql.connector.errors.InterfaceError) 2003: [duplicate]

Facing Error: (mysql.connector.errors.InterfaceError) 2003: Can't connect to MySQL server on '%-.100s:%u' (%s) (Warning: %u format: a number is required, not str) (Background on this error at: https:/...
Abhishek Yadav's user avatar
0 votes
0 answers
26 views

mysql-connector python, Can't connect to server without database name

I want to connect to mysql server, not just one database then I want to use the 'USE db ' command to switch between them but python wont accept no database name. This is my code: global connection ...
Evo's user avatar
  • 3
1 vote
0 answers
37 views

When exactly is a connection to MySQL server secure?

I'm trying to understand the exact meaning of SSL while trying to connect to a MySQL server (via mysql-connector-python). I have MySQL (v5.7) setup locally and I have 2 users. One (root) is the ...
Vaibhav's user avatar
  • 547
-1 votes
0 answers
54 views

How to write pytest for mysql connection using 'with' in python

I am new to python and pytest. I have mysql-util.py which calls mysql db and retrieves rowId. I am trying to write a sample pytest case for the below function get_row_id(). I have referred multiple ...
Nani's user avatar
  • 55
0 votes
1 answer
39 views

Is this the right way to structure database initialization calls in mysql/python?

I'm new to mysql, python and the mysql Python connector. Wanting to learn best-practice. I have an initialization method to create the db, create the tables and/or populate it with data (depending ...
mr.b's user avatar
  • 933
0 votes
0 answers
11 views

Handling connection to MySQL database problems in Python

I am trying to write a programm that uses MySQL database and came upon a problem that programm got stuck. I found what the problem was - somone cut the power to computer where MySQL server was located....
Vilhelms Balodis's user avatar
0 votes
1 answer
26 views

Extracting MySQLdb column values within Flask

I am trying to program a simple dropdown where I do get data from the MySQLdb connection and cycle woth Flask through the resuls, but the data is not shown correctly. I have consulted and followed ...
Dogra's user avatar
  • 1
1 vote
1 answer
44 views

MySQL syntax error for JSON_CONTAINS when querying for column having array of json objects

What is wrong with the below query. SELECT * FROM contract WHERE application_id="abcdef" AND JSON_CONTAINS(contract_details, '{"name":"~!@#$$%%^&*())_+?><,./:...
santosh's user avatar
  • 4,009
0 votes
1 answer
42 views

Accessing MySQL database with Django

Apologies in advance if this type of question already exists with a solution. I have been trying to get this solved for about 2 weeks now. So I had a Django project, which initially used the default ...
tan_000's user avatar
  • 31
-1 votes
1 answer
55 views

python 3.5 connect mysql 3.23

I want to connect to mysql 3.23 database using python 3.5. I would like to ask which connector is available. Thanks. I'm just starting to learn python. Please help me. I can't load mysql-connector-...
Jirawatl's user avatar
-1 votes
1 answer
25 views

Syntax Error in MySQL integrated with Python

I am trying to code a program that takes input from the user into a variable n, and creates a table in mySQL based on the input. However, I am facing an unprecedented error that just keeps popping up ...
Agrim Arsh's user avatar
-1 votes
1 answer
20 views

I run into the following error when trying to install MySQL connector for Flask

I try to run pip3 install flask_mysqldb command but it throws me the following error this the error screenshot. Any suggestions on how to resolve the error? Thanks. I want to install a python library ...
Saipavan Meruga's user avatar
5 votes
0 answers
131 views

Cannot install mysqlclient on Elastic BeanStalk Instance

How can I get pip to install mysqlclient in Amazon Linux 2/Python 3.8 instance? I am deploying a Django application to Elastic Bean Stalk. While the deployment process is running pip install -r ...
ytobi's user avatar
  • 605
0 votes
0 answers
34 views

Proper Way to Create Executable from PY File [duplicate]

I'm not able to create a proper self-contained executable from my Python code. I recently worked on a project. I coded in Python where I've used MySQL. The modules I've used are tkinter, random, ...
Mohamed Junaid Samiullah's user avatar
0 votes
2 answers
125 views

Unable to connect to GCP cloud SQL from FAST API container using unix_socket

Running the FAST API image is throwing the following error. pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on None") I am using databases for async operations with '...
lakshman's user avatar
-1 votes
1 answer
25 views

MySQL server connection issue

Someone tell me please why the given below error is occurring again and again even i wrote the correct host name. ERROR: django.db.utils.OperationalError: (1130, "Host 'Hostname' is not allowed ...
Ahsan Riaz's user avatar
0 votes
1 answer
27 views

SQL Python throwing error when I am trying to update multiple values in a row

c.execute('update MainDB set name=%s, set opportunity=%s, set value=%s, set stage=%s, set startdate=%s, set lastupdate=%s where rowid = %s',(name,opportunity,value,Stage,startdate,date,rowid)) I have ...
Confused Coder's user avatar
0 votes
1 answer
26 views

python MYSQL, check for a condition OR no records then insert new record

can the below if - else stament be simplifed into a single if (cond1 OR cond2) statement condition 1 would be state== specific value (either a 1 or a 0) and condition 2 would be no records found sql1 =...
Sandman112's user avatar
0 votes
2 answers
120 views

Can't connect to MySQL database with Paramiko, can with sshtunnel

My code was using sshtunnel and connected to my database correctly. However due to a conflict between grequests and sshtunnel I had to switch to using another library for the ssh, and have had most ...
David's user avatar
  • 29
0 votes
0 answers
72 views

Migrating Database in MySql

I am migrating database from Microsoft SQL Server to Mysql server An error occurs when selecting "Microsoft SQL Server" option from Database System The following is the error: connection ...
Abishekk's user avatar
-2 votes
1 answer
54 views

Discord Py ORDER BY - wrong order

@commands.command() async def leader(self, ctx): desc = "" counter = 1 async with aiosqlite.connect(self.DB) as db: async with db.execute( "SELECT ID, ...
Mrcl's user avatar
  • 1
1 vote
1 answer
3k views

Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects

I am trying to install my requirements.txt file, which have many packages, every package has been installed except for mysqlclient. I am using Linux Mint 21.2 Python 3.10, when ever I try to run pip ...
qatesterbecomingprogrammer's user avatar
0 votes
0 answers
24 views

Saving a image with blob type on mysql using django and ReactJS

I would like to save a blob in mysql using django , but I have the following problem sometimes the image is saved as none and sometimes it gives a bad request problem, how can I solve this? Here my ...
Dark Dragon's user avatar
-1 votes
1 answer
50 views

How to update mysql records with variables using Python

I have a local mysql database with some records and I need to create a code to update them using python. I am new of python language but I already have esperience with others language like php and ...
Marcello Gabrielli's user avatar
1 vote
0 answers
11 views

TypeError: not all arguments converted during string formatting_ [duplicate]

Running this bit of code: for row in csv_data: if skipHeader: skipHeader = False continue row = tuple(row) cur.execute("INSERT INTO july VALUES %r" % row, row) ...
coding_upcomer's user avatar
0 votes
1 answer
104 views

Python Error checking using pymysql get errors

I have put together an example python scripts for myself to understand how to connect to a MySQL database using pymysql. It works but in Thonny-Assistant it is showing a few errors and I am asking for ...
Peter_Brown_USA's user avatar
0 votes
0 answers
28 views

Trying to insert collection from mongodb to mysql table

mongodb contains 2 collection with 5 fields each: { "channel details": c, "playlist details": p, "video_ids": v_id, "video details": v, &...
Deepak N's user avatar
-3 votes
2 answers
28 views

How To update columns for particular ids

update particular columns for set of bulk ids. ex: +-------+---------------------------+----------------------------------+ | id | name | companyname | +---...
sudharsanan r's user avatar
0 votes
0 answers
176 views

Lost connection to MySQL server during query - Can't connect to MySQL Server

I am trying to access new, fresh MySQL Server over corporate network, machines are using Windows. MySQL running version 8.0, python is 3.9.13 My code (Variant 1 pymysql) import pymysql def ...
directx995's user avatar
0 votes
0 answers
20 views

Discord Python Bot - sending bot userID instead of client userID?

As title suggest, I have a bot that basically accepts 3 ints via command and stores them in a database by username and user id. i'm now trying to make a command that lets the user recall the ...
racin36er's user avatar
11 votes
3 answers
6k views

Can not install apache-airflow-providers-mysql: pkg-config error

I'm using Debian/Ubuntu, and I am trying to install an Airflow provider in my Python virtual environment: $ pip install apache-airflow-providers-mysql error: subprocess-exited-with-error × ...
masterShifu's user avatar
-2 votes
2 answers
906 views

How to solve error while running pip install mysql on Mac( Exception: Can not find valid pkg-config name)

Already tried re-installing everything. still got this message /bin/sh: pkg-config: command not found /bin/sh: pkg-config: command not found Trying pkg-config --exists mysqlclient ...
Gabriela Martins's user avatar
0 votes
1 answer
44 views

backup mysql database like mysqldump with python not from server but from client

I finished my big project in python which is in short a GUI to administrate a database. The datas stored in the database are really important and i want to be sure that if the server stop functionning ...
d'Elbreil Clément's user avatar
0 votes
1 answer
77 views

Why did my Python script abort within a try block?

My script has been running continuously for about a week. Received this error and the script aborted: Traceback (most recent call last): File "/opt/dba/home/swechsler/library/mysql/bin/./...
Swechsler's user avatar
  • 101
0 votes
0 answers
72 views

React JS Flask API Trouble: Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

This is my first time connecting Flask to React. I am trying to fetch the information from my flask API to use for my React frontend but get Uncaught (in promise) SyntaxError: Unexpected token '<', ...
Cin's user avatar
  • 19
0 votes
0 answers
18 views

Select from a table and insert in another table with different order

With following query I retrieve some names from a table query = "SELECT lastname FROM `firsttable` WHERE grp = 'C' AND av = '0' " Caleb Collins Fiandre Francis Garmont Gavelot Maxima Power ...
Ryan Day's user avatar
  • 125
0 votes
1 answer
337 views

Django ImportError: dlopen(_mysql.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_mysql_affected_rows'

I am setting up local workspace for my Django project with MySQL on a Macbook AIR with M2 chip. All config are migrated from my old Macbook Pro with core i7 using OSX Migration Assistant. I am having ...
black zeng's user avatar
0 votes
1 answer
58 views

python mysql.connecotr raise InternalError("Unread result found")

With: pip install mysql-connector-python import mysql.connector I have a db with millions of rows, so the fetchall() method was causing some memory issues. db_cursor.execute(sql_query, ...
64rl0's user avatar
  • 29
0 votes
0 answers
82 views

Django disable database ssl using python-alpine docker image

I'm trying to create a Django app using docker. Because of some problem, I want to connect with database without using ssl/tls. When I use local environment, or docker image ubuntu, it work fine when ...
nguyện triệu đình's user avatar
0 votes
0 answers
284 views

SyntaxError: source code string cannot contain null bytes

I am trying to run python manage.py makemigrations and the below exception is being thrown. please note that - 1 - I have my own User class in models.py 2 - Two model classes, one inside the app and ...
Eswar's user avatar
  • 25

1
2 3 4 5
65