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

SQLAlchemy ORM: "AttributeError: Could not locate column in row"

I'm learning SQLAlchemy right now, but I've encountered an error that puzzles me. Yes, there are similar questions here on SO already, but none of them seem to be solved. My goal is to use the ORM mode to query the database. So I create a…
Johannes Gontrum
  • 1,130
  • 1
  • 10
  • 12
8
votes
1 answer

Python mysql-connector hangs indefinitely when connecting to remote mysql via SSH

I am Testing out connection to mysql server with python. I need to ssh into the server and establish a mysql connection. The following code works: from sshtunnel import SSHTunnelForwarder import pymysql import mysql.connector with…
bcsta
  • 1,963
  • 3
  • 22
  • 61
8
votes
3 answers

How to connect to AWS RDS MySql database with Python

I am currently trying to connect to my MySql database created on AWS with a python program using the library PyMySQL # !/usr/bin/env python # -*- coding: utf-8 -*- import pymysql host = 'admin.cjp8hsqu4je0.us-east-2.rds.amazonaws.com' user =…
Keriger
  • 101
  • 1
  • 1
  • 3
8
votes
2 answers

pymysql stopped working : NameError: name 'byte2int' is not defined

I am using pymysql in Python to connect to database. It was working fine but now I am getting following error : Traceback (most recent call last) : File "/Users/njethani/Desktop/venv/lib/python3.6/site-packages/pymysql/__init__.py", line 94, in…
nsjethani
  • 119
  • 10
8
votes
4 answers

Error while using pymysql in flask

I am using pymysql client to connect to mysql in my flask API, everything works fine for some days(around 1-2 days) after that suddenly it starts to throw this error Traceback (most recent call last): File…
Bhargav
  • 697
  • 3
  • 11
  • 29
8
votes
2 answers

Fetch data with pymysql (DictCursor)

It seems like a really simple task but I'm having difficulties doing it proper. My SQL Query look like this: self.link = self.db.cursor(pymysql.cursors.DictCursor); self.link.execute("SELECT * FROM crawler_data WHERE id=%d" % id_crawl) And I want…
Marcus Lind
  • 10,374
  • 7
  • 58
  • 112
8
votes
1 answer

pymysql lost connection after a long period

using pymysql connect to mysql, leave the program running for a long time,for example, leave the office at night and come back next morning.during this period,no any operation on this application.now doing a database commit would give this error. …
user2003548
  • 4,287
  • 5
  • 24
  • 32
7
votes
3 answers

Finding source of PyMySQL error - err.InterfaceError("(0, '')")

I am a Discord bot developer, and recently completed an order. The client upon setting the application up on their server initially had no issues, but according to them after running for "about three hours" the program begins spitting a specific…
Sparrow
  • 91
  • 2
7
votes
1 answer

How to ignore pymysql warnings?

Consider this code: import pymysql db= pymysql.connect("localhost","root","","raspi") cursor = db.cursor() cursor.execute("INSERT INTO access(username)VALUES('hello')") db.commit() db.close() when I run it I'll get this…
ArchDevOps
  • 99
  • 1
  • 8
7
votes
1 answer

How to read all data from cursor.execute() in python?

I use PyMysql to connect to my MySQL DB. cursor.execute(query) data = cursor.fetchall() for (id,clientid,timestamp) in cursor: print id,clientid,timestamp I want to sort the data based on timestamp ;like; sortedList = sorted(data, key=lambda…
Ratha
  • 9,434
  • 17
  • 85
  • 163
7
votes
1 answer

SSL Certification Error > hostname doesn't match

I'm trying to connect to Google Cloud MYSQL server using SSL certificates and the python module PyMySQL with the following line: connection = pymysql.connect(host=os.environ['SQL_HOST_IP'], user=os.environ['SQL_USER'], password =…
7
votes
3 answers

Python pymysql - iterate through mysql table key and value

I am new to python pymysql (I used before Ruby with Mysql2 gem), I want to get the key and the value from mysql table and do some actions: For example: dbconnection = pymysql.connect(host=mysql_hostname, user=mysql_username, password=mysql_pass,…
Berlin
  • 1,456
  • 1
  • 21
  • 43
7
votes
1 answer

PyMySQL in Flask/Apache sometimes returning empty result

I have a Flask application, being run in Apache, that relies on PyMySQL. The application provides a series of REST commands. It is running under Python 3. Without providing the entire source, the program is structured as: #!flask/bin/python import…
lochok
  • 363
  • 1
  • 4
  • 20
6
votes
1 answer

Mutlithreading with raw PyMySQL for celery

In the project I am currently working on, I am not allowed to use an ORM so I made my own It works great but I am having problems with Celery and it's concurrency. For a while, I had it set to 1 (using --concurrency=1) but I'm adding new tasks which…
juleslasne
  • 580
  • 3
  • 22
6
votes
0 answers

relationship between pymysql and sqlalchemy

I have used a lot of python pandas and MySQL. but in separated way. in order to achieve better automation task, I start getting to know pymysql. For me, I found some of database action I can achieve only by pymysql+pandas action. however, some of…
Michael Li
  • 647
  • 2
  • 8
  • 20