Questions tagged [pymysql]

PyMySQL is a database connector for Python like MySQLdb.

PyMySQL is a database connector for Python, that means it is a library to enable Python programs to talk to a MySQL server.

It is written in pure Python and works with Python 2.7+ and Python 3.X.

pymysql is a drop-in replacement for mysqldb.

Documentation can be found at https://pymysql.readthedocs.io/

1369 questions
11
votes
1 answer

MySQL connection pool in python?

I'm trying to process large amount of data using Python and maintaining processing status in MySQL. However, I'm surprised there is no standard connection pool for python-mysql (like HikariCP in Java). I initially started with PyMySQL, things were…
11
votes
2 answers

PyMySQL throws 'BrokenPipeError' after making frequent reads

I have written a script to help me work with a database. Specifically, I am trying to work with files on disk and add the result of this work to my database. I have copied the code below, but removed most of the logic which isn't related to my…
11
votes
1 answer

PyMySQL and OrderedDict

I've been using PyMySQL for a while now and created my own wrapper that I'm used to to shorthand writing queries. Nonetheless I've been creating CSV files with OrderedDict because I need to keep the order the same but I realize that if I use…
Paul Carlton
  • 2,785
  • 2
  • 24
  • 42
11
votes
1 answer

Python, sharing mysql connection in multiple functions - pass connection or cursor?

I am opening mysql connection in the main function and use that connection in multiple functions called by the main function. Is there anything wrong with passing cursor from main function instead of passing the connection? I.e.: Pass in cursor from…
Pavel Chernikov
  • 2,186
  • 1
  • 20
  • 37
11
votes
1 answer

Intermittently can't connect to mysql on AWS RDS (Error 2003)

We are having an intermittent issue with connections to our mysql server timing out. The error we are receiving is as following. (2003, 'Can\'t connect to MySQL server on \'\' ((2013, "Lost connection to MySQL server during query…
Zach
  • 141
  • 6
10
votes
2 answers

PyMySQL unable to execute multiple queries

Using the latest version of PyMySQL(0.9.3) I am unable to execute a query string which has multiple SQL statements in it separated by a semicolon(;) My python version is: Python 3.6.5 import pymysql # version 0.9.3 conn = { "host":…
Saif S
  • 301
  • 2
  • 8
10
votes
2 answers

Cannot connect to a local mysql db with sqlalchemy on windows machine

I'm trying to connect to a local mysql DB on my windows machine using sqlalchemy. It works using pymysql, but not with sqlalchemy. Code sqlalchemy: engine = create_engine('mysql+mysqldb://root:mypass@localhost/classicmodels') engine.connect() Gives…
Ron
  • 333
  • 3
  • 10
10
votes
2 answers

PyMySQL Warning: (1366, "Incorrect string value: '\\xF0\\x9F\\x98\\x8D t...')

I'm attempting to import data (tweets and other twitter text information) into a database using Pandas and MySQL. I received the following error: 166: Warning: (1366, "Incorrect string value: '\xF0\x9F\x92\x9C\xF0\x9F...' for column 'text' at row…
Sterling King
  • 163
  • 1
  • 3
  • 13
10
votes
5 answers

Python to mysql 'Timestamp' object has no attribute 'translate'

I'm trying to load a pandas dataframe to a mysql table using Sqlalchemy. I connect using; engine = create_engine("mysql+pymysql://user:password@ip:port/db") I am then simply running; df.to_sql(con=engine, name='Table', if_exists='append',…
Grant McKinnon
  • 445
  • 3
  • 7
  • 17
9
votes
3 answers

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 Optional from sqlmodel import Field, Session,…
joooet
  • 105
  • 1
  • 1
  • 5
9
votes
4 answers

Pandas read_sql() - AttributeError: 'Engine' object has no attribute 'cursor'

I am trying to read data from MySQL query using pandas read_sql() method with python3+sqlalchemy+pymysql I tried to follow the following tutorials…
Adi
  • 407
  • 1
  • 4
  • 13
9
votes
1 answer

flask-login without flask-sqlalchemy or ORM

I am currently using flask-login in my application for user login session management. I am using flask-sqlalchemy, so all working ok. Because of my previous sql experience, I am not fan of ORM. I like to use SQL directly. May be it is because of my…
Jay85
  • 116
  • 2
  • 10
9
votes
3 answers

How to check the status of a mysql connection in python?

I am using pymysql to connect to a database. I am new to database operations. Is there a status code that I can use to check if the database is open/alive, something like db.status.
Yan Song
  • 2,285
  • 4
  • 18
  • 27
9
votes
1 answer

Inserting a list holding multiple values in MySQL using pymysql

I have a database holding names, and I have to create a new list which will hold such values as ID, name, and gender and insert it in the current database. I have to create a list of the names which are not in the database yet. So I simply checked…
Alice Jarmusch
  • 467
  • 1
  • 7
  • 20
9
votes
3 answers

Can't connect to Cloud SQL using PyMySQL

I'm trying to connect to Cloud SQL from a Python application (using PyMySQL 0.7.9) running on top of Google App Engine. My connection string looks like this (credentials are fake of…
Niklas9
  • 8,816
  • 8
  • 37
  • 60
1 2
3
91 92