Created
July 29, 2013 20:27
-
-
Save matthewcornell/6107508 to your computer and use it in GitHub Desktop.
how to hang mysql from python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mysql.connector | |
conn1 = mysql.connector.connect(database='test', user='test', password='test') | |
curs1 = conn1.cursor() | |
curs1.execute("create table foo(id text)") | |
curs1.execute("select * from foo where random()") | |
# -> mysql.connector.errors.ProgrammingError: 1305 (42000): FUNCTION test.random does not exist | |
conn2 = mysql.connector.connect(database='test', user='test', password='test') | |
curs2 = conn2.cursor() | |
curs2.execute("drop table foo") | |
# -> hangs! (see "Waiting for table metadata lock" below) | |
# mysql> show processlist; | |
# +----+------+-----------------+------+---------+------+---------------------------------+------------------+ | |
# | Id | User | Host | db | Command | Time | State | Info | | |
# +----+------+-----------------+------+---------+------+---------------------------------+------------------+ | |
# | 4 | root | localhost | test | Query | 0 | init | show processlist | | |
# | 5 | test | localhost:49460 | test | Sleep | 36 | | NULL | | |
# | 6 | test | localhost:49461 | test | Query | 15 | Waiting for table metadata lock | drop table foo | | |
# +----+------+-----------------+------+---------+------+---------------------------------+------------------+ | |
# 3 rows in set (0.00 sec) | |
# mysql> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment