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).
3,059
questions
-1
votes
0
answers
24
views
Columns to have multiple comma seperated values for a particular record in MySql [duplicate]
I have following table now I want my Degree and Speciality table to have comma separated values for a particular MDMID and BatchTimeStamp from that table
Is there anyway to achieve it in MySQL?
I am ...
-1
votes
0
answers
13
views
Read and split MySql column containing single and multiple comma sperated values
I have a landing table that has the column name speciality which can have single or multiple comma sperated values.
Now i want to map the corresponding specialityId to each speciality that is in the ...
0
votes
1
answer
24
views
Error in SQL syntax: How can I update a null record with a datetime value in MySQL Python
I want to set NULL Shipped Date values in a MYSQL table to today's current date and time. So for example, an Order with ID 11077 have a null shipped date in the table. I want to change this specific ...
0
votes
0
answers
13
views
Calling function from sshtunnel.SSHTunnelForwarder
How do I call function getRowById() in sshtunnel.SSHTunnelForwarder from other file in python?
I create a function inside with...as tunnel as it doesn't work outside with...as tunnel. I can call ...
0
votes
0
answers
30
views
unable to solve ModuleNotFoundError: No module named 'mysql' on spyder on windows (tried all available solutions)
unable to solve ModuleNotFoundError: No module named 'mysql' on spyder on windows (tried all available solutions) but couldnt resolve
0
votes
3
answers
32
views
MySQL-Python Wont create the table
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,\
...
-3
votes
0
answers
29
views
ISSUE WITH HAVING CLAUSE AND SQL AGGREGATE FUNCTION [duplicate]
This is my employee_details table
[In my employee_details table I need details of all employee having salary greater then avg(salary), It should return me two rows but I'm getting only one row ]
...
0
votes
0
answers
41
views
Average number of bathrooms and bedrooms; Pandas
I have an SQL code that I want to convert to python.
The task is to find the average number of bedrooms and bathrooms by city and property type. Here's the SQL code:
SELECT city, property_type, SUM(...
0
votes
1
answer
30
views
MySQL-python Delete Query is NOT deleting data, but no error is displayed
I'm working on a terminal-password-manager with Python and SQL, everything works fine except for the delete function, I've managed to set it up in a way where no errors are displayed, however the ...
-2
votes
0
answers
17
views
SQL jobs for beginners & learning path [closed]
I need projects so I can practice MySQL skills and upscale my knowledge. If you need something to be done for you, do not hesitate to contact me.
1
vote
0
answers
18
views
How to define a `select` function with table name in `pymysql`? Is it safe for SQL injection? [duplicate]
I need to query some similar elements in several similar tables, so I want to define a generic function to reduce code repetition.
Such as,
...
def my_select(tb_name,some_key):
...
cursor....
0
votes
0
answers
22
views
updation of mysql table using parameterised arguments in sql query with python
I am trying to update a mysql table using python using a parameterised arguments ( %s) in sql query.
The columns to be updated have value of string data type.
My function is given in code area.
Brief ...
0
votes
0
answers
18
views
I have been trying to execute the following query but it shows Eror: Not all parameters were used in the SQL statement. What changes should I do?
This is the code I have written to get Patient Details from a table Patients but it is not working properly.
import mysql.connector as sql
mysql= sql.connect(host="localhost", user="...
0
votes
0
answers
13
views
MySQL syntax error when inputting file path into table using python mysql.connector [duplicate]
I'm trying to take an input from the user in the form of a file path and then insert it into a table using string injection but I keep getting the error
mysql.connector.errors.ProgrammingError: 1064 (...
0
votes
0
answers
13
views
My django project is missing a lot of defaults and installed packages are not working
When I make my django app there is typically a default sqlite3 that comes with it but for some reason it does not show up so I created a database in the MySQL workbench and then in my settings.py I ...
0
votes
0
answers
48
views
NameError: name '_mysql' is not defined on Mac A1 Monterey
I am trying to include mysql into my django and face the error of
in <module> version_info, _mysql.version_info, _mysql.__file__
NameError: name '_mysql' is not defined
I think this might be an ...
-1
votes
0
answers
52
views
ModuleNotFoundError: No module named 'MySQLdb' with MySQL-python package
I am using Mac Pro. I have installed "MySQL-python==1.2.5" package in virtualenv_backend.
pip install pymysql-python==1.2.5
Then I using pip list to check if it installed it is showing in ...
0
votes
1
answer
43
views
connect mysql database using flask
i am trying to connect the database mysql using flask-python . i create a 'users' name table have two columns 'fname' 'lname' datatype string in my database name 'login'
code
from flask import ...
1
vote
1
answer
40
views
MYSQL 0.0.2 package is not installing when running pip install -r requirements.txt
I am trying to install the 'mysql' package ( Version 0.0.2) , using pip install -r requirements.txt
But I am facing the following error:
Collecting mysql==0.0.2
Using cached mysql-0.0.2.tar.gz (1.9 ...
0
votes
0
answers
63
views
2055: Lost connection to MySQL server at 'localhost:3306'
I keep facing this error - connection drops at times. 2055: Lost connection to MySQL server at 'localhost:3306', system error: 1 [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:2536)
I am ...
0
votes
0
answers
25
views
installing mysqlclient locking failed
I am using python3.9 in django framework, for that I have to install mysqlclient. But error is coming when I try
pipenv install mysqlclient
output like this as error:
Courtesy Notice: Pipenv found ...
1
vote
1
answer
71
views
How to Read Data from CSV row by row and store in database
I have a csv file with 20 records that need to stored in a table inside a database. I am trying to read every row line by line but not sure how to pass it to a function which would check the ...
0
votes
0
answers
32
views
connection database mysql with python 3
I received a project in which my task is connect the database to python Finding many Errors when I connect the database mysql with python 3. I installed mysql driver ,mysql-connector
import mysql....
0
votes
1
answer
30
views
SQL obtain all rows where rows with this id hasn't value 'a' [closed]
I have a table with fields 'id', 'data', 'var' where id can be repeated. For example:
id data var
1 data1 a
1 data2 b
2 data3 a
3 data4 b
4 data5 a
I want get all ...
1
vote
1
answer
24
views
What is the alternative of mysqlcheck in python3?
I need to use mysqlcheck cmd for optimizing tables in the database. I've created a Lambda function in python for the whole process, now to execute the whole process first I need to optimize all tables ...
0
votes
0
answers
9
views
How to make mysqlclient works with Python2.7 on macOS Monterey
I installed mysqlclient version 1.4.6 via pip for Python 2.7.18 with no errors. But when I connect to test db I always get the error:
>>> import MySQLdb
>>> MySQLdb.connect(user=&...
0
votes
0
answers
22
views
How to decode using Python-MQTT get values from two payloads?
Currently there are two payloads with 4 seconds delay being sent by a sensor and to compute the power of the application, data from both payloads must be decoded and their end values need to be ...
0
votes
0
answers
32
views
No file or directory found despite having the file in python to execute an sql file
In relation to this question: Unexpected unindent python to execute an sql query
This is my python script:
import mysql.connector
def executeScriptsFromFile(filename):
fd = open(filename,'r')
...
1
vote
1
answer
35
views
MySQL connection with Python through PythonAnywhere
I want to connect to MySql database using Python through PythonAnywhere, without creating a Flask/Django application.
I have seemingly managed to connect through MySQLdb, using the code below, but I ...
0
votes
0
answers
12
views
how to remove the error in parameterized query in mysql using python
i was trying to build a billing app where the user give input about the customer detail and products that person buy....in the billing app the data is stored in a table the name of the table is ...
0
votes
0
answers
20
views
I keep losing connection on MySQL-python query over the hours
So I normally use the typical inserting process to my DB, but after some hours of working perfectly, It loses connection. This is supposed to repeat every minute, works perfectly until it does not.
...
0
votes
0
answers
13
views
reading a large MySQL table with MySQLdb
Using mysqlclient 2.0.3 the docs say this can be done with fetchone(). I wrote a very short test script:
c.execute('select * from myTable')
:
c.execute('select * from items_csv')
...
0
votes
1
answer
25
views
Getting Data between yesterdays date and todays date in MYSQL using Python
I run this query to fetch some data
Query = my_cursor.execute("SELECT concat(FORMAT(Sum(RealCash),0)) FROM fantasy.Transaction WHERE (TransactionType=4 AND Status=1) AND DateModified BETWEEN '...
0
votes
0
answers
19
views
Can't find solution to resolve this error MySQLdb._exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now")
I apologize in advance that I will not be able to provide a code example.
All what I can show is the traceback error that I don't understand:
Traceback (most recent call last):
File "/home/...
0
votes
0
answers
31
views
I keep losing connection with the MySQL server after some hours
I have a python script which works as a counter for a production line that it basically records a product has passed through the sensor's beam. Aside from this, the code has two threads that works as ...
0
votes
0
answers
47
views
ERROR: Failed building wheel for MySQL-python How do I install MySQL-Python?
I was building a Django app with a mysql database, everything works fine but to deploy the app with mysql database's data, I need to install 'MySQL-python' library. When I try to install it, I get ...
0
votes
1
answer
54
views
Getting OperationalError: (2000, 'Unknown MySQL error') when accessing mysql database using celery and django
I am using celery with my django application. My application works fine with mysql database, but I am getting (2000, 'Unknown MySQL error') when celery tries to access the database. This happens only ...
-2
votes
1
answer
67
views
insert list as a new column mysql
I have a list of string values new_values and I want to insert it as a new column in the companies tables my mysql database. Since I have hundreds of rows, I cannot manually type them using the ? ...
0
votes
0
answers
59
views
update col values using python list mysql
I read a column's length in the code given below. Then, I have a list fakeNames whose length is equal to the column's original length.
How can I replace the values of the original column ...
0
votes
1
answer
51
views
connect to mysql database python3.9
I am using a conda virtual environment with Python version 3.9 on macOS.
I am trying to connect to a mysql db like this:
import MySQLdb
# Connect
db = MySQLdb.connect(
host="jgsahkjrds....
0
votes
2
answers
66
views
SQL Select order by index of value in an array
I have one array of strings [“text1”, “text2”, “text3”] which happens to be saved as JSON array field on TableA
uniqueID
strings
1
["text1","text2","text3"]
And a ...
0
votes
0
answers
41
views
How to Find size of tables from information_schema that is filtered on a certain column value in mysql
I'm trying to see the storage consumption from stale devices (pid =0 )
Main table - master_dev.legend_device
stale device count - select count(*) from master_dev.legend_device where pid =0.
Now these ...
0
votes
1
answer
54
views
count of value available in comma separated column
I have a table in mysql as mentioned below :
create table test (
id int,
page_id varchar(2),
name varchar(255));
insert into test values
(1,'P1','a,b,c,d,e'),
(1,'P2','f,h,z,a,c'),
(1,'P3','x,yz,g,c'...
1
vote
0
answers
28
views
Stuck with a MySQLdb SSL connection error in Python2.7
I have to maintain an old website built using Python2.7 that needs to continue working until we've finished creating a completely new version with more modern tools. Now this old website needs access ...
0
votes
0
answers
27
views
Weird MYSQL behavior when python program is left running idle for more than 1 h
Good day.
I have a tkinter application that uses mysql database (db located in linux server). No fancy operations just basic read & write operations. I found out that whenever I leave application ...
0
votes
0
answers
7
views
when i use scrapy make data in MySQLdb,insert html content,return problem
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right ...
0
votes
1
answer
31
views
How to match column with similar but different formats from 2 MySQL tables to join them into one MySQL table?
I wanna know how to join 2 tables into one based on a column named 'Chamber_ID', however, with 2 different formats. Table A has the column with the format: SG_QRA_SGHAST_0001, 0002, etc. and Table B ...
1
vote
2
answers
37
views
Is there any way to get data of (Yesterday) withing a particular timestamp using mysql
I'm using mysql workbench, And i need to retrive data of yesterday, but i want the data from a particular timestamp for eg data from 00:00:00 to 12:00:00 how can i do that? And i dont want to change ...
1
vote
1
answer
18
views
Why does my SQL query keep throwing an error when I am using the right column name and the correct statement? [duplicate]
I am trying to create a book Database system using MySQL Python and Flask. My 3 columns in my Books table are title, author, and publish_year.
I have a SQL Command that says
"SELECT * FROM Books ...
0
votes
2
answers
36
views
Updating MySQL database with python
I having some issues to update my database, it keeps throwing the same error
ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL ...