question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mock_s3 interfering SQLAlchemy calls to local MySQL databases

See original GitHub issue

Please consider the below code snippet.

#!/usr/bin/env python

from sqlalchemy import create_engine
from sqlalchemy_utils import database_exists
from moto import mock_s3



@mock_s3
def test_foob():
    database_exists("mysql+pymysql://user:password@127.0.0.1")

If we run this with pytests, it will fail with the below error.

 sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query')

However, if we remove the @mock_s3 decorator, it passes. Any idea why this is happening?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
spuleccommented, Mar 16, 2017

Great, thanks for opening the issue!

1reaction
kennydocommented, Mar 16, 2017

master looks good to me!

(in python3.4)

>>> with moto.mock_s3():
...     pymysql.connect(host='127.0.0.1', user='root', db='foo_test')
...
<pymysql.connections.Connection object at 0x102cc9da0>
Read more comments on GitHub >

github_iconTop Results From Across the Web

SQLAlchemy can't connect to local MySQL - Stack Overflow
your MySQL server's socket is likely not at /tmp/mysql.sock so the driver can't connect. Mine is at /var/run/mysqld/mysqld.sock, ...
Read more >
MySQL and MariaDB — SQLAlchemy 2.0 Documentation
Upon first connect, the SQLAlchemy dialect employs a server version detection scheme that determines if the backing database reports as MariaDB.
Read more >
Using SQLAlchemy to access MySQL without frustrating ...
This library has a number of problems: 1) it is Python 2 only, and 2) it requires compiling against the MySQL C library...
Read more >
Connect to MySQL with SQLAlchemy - In Plain English
In this article, you'll learn how to connect to a database with SQLAlchemy. Furthermore, you'll see some examples, which should get you ...
Read more >
SQLAlchemy Tutorial 1 – Connect Python to MySQL ...
This video is a step by step tutorial on how to connect Python to various database engines including MySQL, SQLite and PostgreSQL and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found