Questions tagged [pymysql]
PyMySQL is a database connector for Python like MySQLdb.
1,302
questions
-1
votes
0
answers
19
views
show the result of a cursor [duplicate]
your help please, I try to show the result of the cursor but if I use a for it gives this error
---> 31 for row in mycursor:
32 print(row)
33 mycursor.close()
TypeError: 'int' object ...
0
votes
1
answer
35
views
Pymysql UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3
im using pymysql, Binlog2sql every thing works fine with English characters
the connection string im using is
conn_setting = {'host': args.host, 'port': args.port, 'user': args.user, 'passwd': args....
0
votes
0
answers
58
views
Execution failed on sql 'SELECT name FROM sqlite_master WHERE type='table' AND name=?;':
How can I easily write my pandas dataframe to a MySQL database using mysql.connector?
import mysql.connector as sql
import pandas as pd
db_connection = sql.connect(host='124685.eu-central-1.rds....
1
vote
1
answer
17
views
pymysql and BEFORE INSERT trigger problem
I have a DB table which looks like
CREATE TABLE `localquotes` (
`id` bigint NOT NULL AUTO_INCREMENT,
`createTime` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`tag` varchar(8) NOT NULL,
...
0
votes
0
answers
51
views
pymysql.err.OperationalError: (1045, "Access denied for user 'MYID@localhost' (using password: YES)")
Trying to use pymysql to connect but receive the following error.
pymysql.err.OperationalError: (1045, "Access denied for user 'MYID@localhost' (using password: YES)")
ssl_path = '/Users/...
0
votes
0
answers
23
views
Long running Celery task result in mysql 104 Connection reset by peer
At my Django application, I use celery to process very long-running conversion tasks (video, audio and picture encoding). In general everything is working as expected, but sometimes a task takes ...
0
votes
0
answers
10
views
pymysql: cursor after commit to database returns old values in multithreading mode [duplicate]
Two threads alternately accessing the database.
Both threads connect to the database at the same time. The second thread (15996) is waiting for the first one (38808) to update the data in the table. ...
0
votes
0
answers
18
views
PyMySQL foreign key variable isn't defined in query (API related)
So I'm trying to add records into a table with a foreign key. The data that I want to insert (original_ticket_price and purchasing_ticket_price) comes from an API and they're defined at the top of my ...
-1
votes
0
answers
18
views
Lost connection to mysql during query
I am using pymysql library to get connected to mysql DB in the following way :
conn = pymysql.connect(host = 'hostname', user = 'user_name', password = 'password', db = 'db', connect_timeout = ...
0
votes
0
answers
28
views
Python:: Use pymysql.connect() to Connect to MySQL Docker Container
Trying to build off this post and this post and this tutorial, I'm attempting to write a Python script that can connect to my MySQL Docker container. I'd like to use the pymysql library and then the ...
0
votes
0
answers
15
views
MySQL Lock Timeout on Insert (with no dependencies)
I have a MySql Table with the following structure:
Field type Key Extra
id int(11) PRI auto_increment
shop_id varchar MUL
target_count int(11)
I only write ...
0
votes
0
answers
29
views
PyInstaller - Importing multiple modules
I am trying to port over three modules:
import csv
import requests
import pymysql.cursors
I hope this is enough information. I then use the following command:
pyinstaller speakeretl.py --hidden-...
0
votes
0
answers
44
views
pymysql.err.DataError: (1366, "Incorrect integer value:
Getting this error, while trying to sent information to database via this code in python:
with open('ypatybes_paruosta.csv', encoding='utf-8') as data2:
csvreader = csv.reader(data2, delimiter = ';...
0
votes
0
answers
22
views
for creating table in pymysql
why there is an error in creating table like : (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at ...
0
votes
1
answer
13
views
pymysql error attempting to run query : sqlalchemy.exc.ProgrammingError
I am running a query using pymysql and passing a string as a parameter for the where clause condition. Code and Error Traceback below:
import pandas as pd
# mysql connection
import pymysql
from ...
0
votes
1
answer
33
views
TypeError - Attempting to SQL Insert : sequence item 0: expected str instance, dict found
I have a fairly large pandas DataFrame that I am attempting to INSERT into a MySQL table.
import pandas as pd
# mysql connection
import pymysql
from sqlalchemy import create_engine
user = 'user'
pwd ...
0
votes
0
answers
27
views
OperationalError: (pymysql.err.OperationalError) (1241, 'Operand should contain 1 column(s)')
I am receiving an Error when attempting to insert pandas dataframe to MySQL.
# mysql connection
import pymysql
from sqlalchemy import create_engine
user = 'user'
pwd = 'xxxxx'
host = 'x.com'
port = ...
0
votes
0
answers
63
views
How to read a table from MySQL work bench in colab
I have referred various articles in stackoverflow and external sources but somehow unable to get answer for this. I want to read a table from MySQL workbench database into a dataframe in colab.
1st ...
0
votes
1
answer
25
views
Best way to separate python anywhere pymysql database connections using qgtunnel (quotaguard)?
We are running 15-20 different python anywhere scripts that all talk to the same database. The script are scheduled through different tasks that are sometimes running simultaneously and we get the ...
0
votes
0
answers
20
views
Flask App loses connection to MySQL database after about a day
I'm using python flask as a backend, running it as a service in the GCP instance. It is working correctly once started the service. But after a day when I try to make an API call it losses its ...
0
votes
1
answer
29
views
Python3 Loop Through Array of DBs Then Connect
I am trying to loop through a number of mysql hosts which have the same connection info and execute the same query on each of them & fetch the results.
I'm still learning python & am stuck on ...
0
votes
1
answer
34
views
Python mySQL query - date between is slow unless LIMIT is added
Having a strange issue with pymysql and python. I have a table where date_rec is one of 3 columns composing a primary key. If I do this select, it takes forever to get the result
query = f"...
0
votes
1
answer
50
views
Python/Flask query returning empty table with correct number of cells
I'm doing this python flask project.
When I'm executing a query, the resulting webpage shows the resulting table with the correct number of rows and columns and cells but all the cells are empty.
[...
0
votes
1
answer
47
views
Trac MariaDB: AttributeError: 'NoneType' object has no attribute 'encoding'
I am trying to run trac on one container and install MariaDB on another container, on the trac container when I am trying to initialize the environment using trac-admin /path/to/env initenv I am ...
0
votes
0
answers
39
views
pymysql & RDS IAM user
Has anyone been able to connect to an RDS host using an IAM user with Pymysql?
https://gist.github.com/kave/4fcdef69ae3007148190516e1e11b48d
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/...
0
votes
0
answers
39
views
PyMySQL table name placeholder
I know this has been asked a million times, but noone seems to provide an alternative...
So this doesn't work:
DW = pymysql.connect(...)
table = "myTable"
with DW.cursor() as cur:
cur....
0
votes
0
answers
73
views
Error 2013, 'Lost connection to MySQL server during query
I'm trying to connect to my mySQL server through a python script, using the pymysql library.
I tried to see the other questions already asked, they led me to set: connect_timeout=31536000, ...
0
votes
1
answer
21
views
How to update a column based on counts from another table?
I need to update the table actor, column numCharacters, depending on how many times each actor's actorID shows up on the characters table.
I have the following code:
cursor = connection.cursor()
...
0
votes
1
answer
41
views
Deleting Row with PyMYSQL
I'm trying to delete rows in 2 tables (actor and characters) when the actor is in less episodes that numEpisodes, a parameter passed in. I've got the following code:
cursor = connection.cursor()
...
0
votes
0
answers
42
views
Python MySQL Commands out of sync even after opening a new cursor
I have written a function to format and execute .sql files for me:
def executeScript(pathToScript : str , connection : Conn.MySQLConnection , *args) -> list[tuple] | None:
#executes a script
...
0
votes
0
answers
42
views
pymysql.err.OperationalError: (2006, "MySQL server has gone away (TimeoutError(110, 'Connection timed out'))") in Pymysql pooling
I am using Pymysql pooling for managing connection pools in our flask project.
But getting error like:
pymysql.err.OperationalError: (2006, "MySQL server has gone away (TimeoutError(110, '...
1
vote
1
answer
885
views
SQLModel: sqlalchemy.exc.ArgumentError: Column expression or FROM clause expected,
I am using the SQLModel library to do a simple select() like described on their official website. However I am getting Column expression or FROM clause expected error message
from typing import ...
0
votes
0
answers
76
views
Having Issues connecting to MySQL Database build from Docker Image with Python (PyMySQL/SQLAlchemy)
I have a Docker Image that builds a MySQL Database from a SQL text file based on a docker-compose.yml file
I've added on to the script with python command to run a python script just once after the ...
0
votes
0
answers
34
views
Update RDS timeout with sqlalchemy
I am connecting to an RDS instance with sqlachemy. I am reading the data from the table with fetchmany. It takes a minute or two to process the data, before getting the next chunk. Unfortunately, I ...
1
vote
1
answer
215
views
Can't connect to MySQL server on 'database' ([Errno 111] Connection refused
I'm trying to create a flask-mysql app and deploy it using docker.
This is my app.py file:
import mysql.connector
from flaskext.mysql import MySQL
from flask_wtf import FlaskForm
from wtforms import ...
0
votes
0
answers
147
views
Errno 104 Connection reset by peer and Errno 32 Broken pipe Flask WebAPP
I am completely new to Flask Web development, I build this website https://justfortrial.com using flask framework, it works great in my local machine, but when i uploaded it to the server, it started ...
0
votes
1
answer
488
views
Ansible - The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required
My ansible code looks like this:
---
- name: Install python
apt:
pkg: "{{ item }}"
update-cache: yes
state: latest
with_items:
- python
- python-dev
- name: Install ...
-1
votes
1
answer
28
views
Custom Exception for own function
I have a function in my fucntions.py that creates a MySQL database or connects to it if the database exists. It works well.
class InvalidLoginError():
def __init__(self, message):
self.message = ...
0
votes
2
answers
117
views
django framework: get value from django.db.models.fields.IntegerField
How can I get value from class django.db.models.fields.IntegerField?
I want get 1 from admin field.
This is python code: model class and function view
from django.db import models
from django.db ...
0
votes
0
answers
406
views
python3.9 pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([Errno 61] Connection refused)")
pls tell me how to deal with the problem
import pymysql
conn = pymysql.connect(host='localhost',port=3306,user ='root',password ='123456',database ='account',charset ='utf8')
cursor ...
0
votes
0
answers
37
views
pd.read_sql_query: 'params' arg (<class 'list'>) can be only a tuple or a dictionary
I am receiving the error:
'params' arg (<class 'list'>) can be only a tuple or a dictionary.
My code is follows:
conn = pymssql.connect(server='server', user='user', password='pwd', database='...
0
votes
1
answer
838
views
PyMysql error : Packet Sequence Number Wrong - got 1 expected 0
I saw in the stackoverflow and another coding example sites which this topics discussed.
But I cannot find any mature solution about it, is anyone fix this error ?
Error Message:
ERROR:root:Can't ...
0
votes
1
answer
80
views
Python MySQL Query Not working (Something went wrong format requires a mapping)
I am trying to pull a query from my database and I am receiving this error when trying to run it: Something went wrong format requires a mapping.
I'm using flask in Python and pymysql.
This is my ...
0
votes
0
answers
31
views
Connection.commit() not uploading all rows to database
I am trying to populate a MySQL database table from a CSV file using PyMySQL. The CSV file has approx 948,000 rows. The script works fine but only approximately 840,000 rows appear in the database, I ...
0
votes
0
answers
118
views
Is pandas to_sql() method allows us to specify database name
I created a sqlalchemy engine using the db as default_db
engine = sqlalchemy.create_engine('mysql+pymysql://username:password@hostname/default_db')
When I try to insert a record into a table test ...
0
votes
1
answer
49
views
whats the right way for read MySQL database with django
I'm new to django
I have a local application I wrote in python that writes scientific data to a MySQL database hosted on a digital ocean droplet that also runs django.
I'm experiencing an intermittent ...
0
votes
0
answers
55
views
when using pymysql , i cannot connect to server "error 1045 : Access Denied for user". What should I do?
I'm using Python.
I can connect my localhost in MySQL. There's no problem
but there are another external server and Problem is I cannot connect that server with error code (1045, "Access denied ...
1
vote
0
answers
40
views
SQLAlchemy - Closing Session Blocks Code Execution
I have a query that runs as a batch using SQLAlchemy yield_per. This is a long duration query and I wanted to have a time limit for how long I run this query for. When the time limit is crossed I ...
0
votes
2
answers
66
views
How do I make this code write data to the database?
There's a problem - for some reason I don't understand, the code doesn't want to write a value to the database. The concept of the code is as follows - a person sends a message and the bot writes his ...
0
votes
1
answer
50
views
PyMySQL and Database
My current school assignment is requiring us to create a library system to manage both members and books. I am using PyMySQL to create the codes in the back. I am also using Tkinter to do the front-...