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
6
votes
3 answers

How to insert a Pandas Dataframe into MySql using PyMySQL

I have got a DataFrame which has got around 30,000+ rows and 150+ columns. So, currently I am using the following code to insert the data into MySQL. But since it is reading the rows one at a time, it is taking too much time to insert all the rows…
John Doe
  • 89
  • 1
  • 2
  • 7
6
votes
2 answers

Automating database creation for testing

For speedier testing it's nicer to use a memory-based sqlite, but it's still necessary once in a while to use MySQL for testing that more closely matches production. To avoid a dry discussion/abstract question, the code below inserts a couple of…
Calaf
  • 10,113
  • 15
  • 57
  • 120
6
votes
2 answers

How to escape the % and \ signs in pymysql using LIKE clause?

I want to find something like "probability: 10%" or "10% high" in my 'events' column, but when I used the code below: conn = pymysql.connect(host="localhost", port=3306, user='myid', passwd='mypwd', db='mydb', charset='utf8') curs =…
Park
  • 364
  • 3
  • 14
6
votes
3 answers

PyMySQL Access Denied "using password (no") but using password

Headscratcher here for me. I am attempting to connect to a database on my local MySQL 8.0.11.0 install from Python. Here's the code I'm using : conn = pymysql.connect(host='localhost', port=3306, user='root', password='placeholder',…
paulmiller3000
  • 436
  • 8
  • 24
6
votes
2 answers

Error Keyerror 255 when executing pymysql.connect

Here is the code import pymysql pymysql.connect( host='localhost', port=3306, user='root', password='iDontWannaSay', db='iDontWannaShow', charset='utf8' ) and the error Traceback was: data is…
Payne Waston
  • 63
  • 1
  • 1
  • 3
6
votes
1 answer

MySQL "delayed commit ok done" and performance

I am using AURORA MySQL on AWS. When I run show Processlist I see lots of delayed commit ok done I want to ask that does it hinder in performance? If Yes, how dO I imrpove it? I am using PyMySQL, a Python based library and I do use .commit after…
Volatil3
  • 14,253
  • 38
  • 134
  • 263
6
votes
1 answer

Python, pymysql class encapsulation of SSCursor not working as expected

The following works: class DB(): def __init__(self, host, user, password, db): self.conn = pymysql.connect( host = host, user = user, passwd = password, charset = 'utf8', …
alfadog67
  • 831
  • 7
  • 28
6
votes
2 answers

sqlalchemy insert - string argument without an encoding

The code below worked when using Python 2.7, but raises a StatementError when using Python 3.5. I haven't found a good explanation for this online yet. Why doesn't sqlalchemy accept simple Python 3 string objects in this situation? Is there a…
haudarren
  • 425
  • 1
  • 4
  • 12
6
votes
3 answers

AWS Unable to import module 'app' : no module named Pymysql

I am using the AWS Console and trying to add data to a MySQL table using a Lambda function. Whenever I try to test the function, I get the following error: Unable to import module 'app' : no module named pymysql Its acting like pymysql is not in…
Darth Vadr
  • 71
  • 1
  • 1
  • 4
6
votes
3 answers

PyMySQL executemany with ON DUPLICATE

I have a list composed of dictionaries called member that I was inserting on a database like so # Executes query for each dictionary in member. cursor.executemany("INSERT INTO `Citizens` (`Handle`,`Org`,`Role`, " …
Bernardo Meurer
  • 2,295
  • 5
  • 31
  • 52
6
votes
2 answers

Python3 - 'Lock wait timeout exceeded; try restarting transaction' and only process on the database

Using Python I am consistently getting an (1205, 'Lock wait timeout exceeded; try restarting transaction') error whenever I try to insert into a particular table. However, when I try to insert directly from the MySQL console, it works just fine.…
user2694306
  • 3,832
  • 10
  • 47
  • 95
6
votes
1 answer

Getting broken pipe when passing mysql connection to a python thread

I'm trying to pass a mysql connection to a thread in python. If i do the initialization of the mysql inside the worker class, there is no error. However, it might be costly for the connection so I tried just passing the mysql connection from the…
Ninz
  • 231
  • 3
  • 11
5
votes
3 answers

ModuleNotFoundError: No module named 'pymysql' in jupyter

I am getting below error after importing pymysql in jupyter notebook. Please help me to find error. import pymysql print("Welcome") ModuleNotFoundError in () 1 import pymysql 2 print("Here") …
Sourav_Bharadwaj
  • 175
  • 3
  • 11
5
votes
0 answers

Pymysql error `pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query ([Errno 104] Connection reset by peer)')`

When I use Pymysql to connect to a Mysql database and create SScursor to query a stored procedure that returns about 600,000 pieces of data and processes that data every time it returns a day, the code is as follows: def…
burningLk
  • 51
  • 2
5
votes
5 answers

pymysql.err.InternalError: Packet sequence number wrong - got 45 expected 0

I am trying to connect to mysql database via pymysql. Everything works when I SSH into the database via terminal. So, that information is correct. However, when I put the same information in using pymysql, I get the following…
Brad Ahrens
  • 4,864
  • 5
  • 36
  • 47