boglin / pymysql Goto Github PK
View Code? Open in Web Editor NEWThis project forked from pymysql/pymysql
PyMySQL: Pure-Python MySQL Client
Home Page: http://www.pymysql.org/
License: MIT License
This project forked from pymysql/pymysql
PyMySQL: Pure-Python MySQL Client
Home Page: http://www.pymysql.org/
License: MIT License
Given that the CLIENT.MULTI_STATEMENTS flag is set, it is valid for the init_command supplied by the connection contain multiple statements. Since on one ok_packet is read this causes subsequent queries to return unexpected results since client/server are out of sync.
Demonstrated by:
def test_init_command(self):
conn = pymysql.connect(
init_command='set time_zone="+00:00"; set max_join_size=1000',
**self.databases[0]
)
c = conn.cursor()
c.execute('select "foobar";')
self.assertEqual(('foobar',), c.fetchone())
conn.close()
MySQLdb provides a second argument to connection's escape method where an 'encoders' dict can be supplied.
For compatibility with existing code could this be added to PyMySQL?
From MySQLdb, _mysql.c:
static char _mysql_escape__doc__[] =
"escape(obj, dict) -- escape any special characters in object obj\n\
using mapping dict to provide quoting functions for each type.\n\
Returns a SQL literal string.";
Proposed test case:
def test_escape_custom_object(self):
con = self.connections[0]
cur = con.cursor()
class Foo(object):
value = "bar"
encoder = lambda x: x.value
self.assertEqual(con.escape(Foo(), encoders={Foo: encoder}), "bar")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.