@@ -145,7 +145,7 @@ def test_issue_16(self):
145
145
146
146
@unittest2 .skip ("test_issue_17() requires a custom, legacy MySQL configuration and will not be run." )
147
147
def test_issue_17 (self ):
148
- """ could not connect mysql use passwod """
148
+ """could not connect mysql use passwod"""
149
149
conn = self .connections [0 ]
150
150
host = self .databases [0 ]["host" ]
151
151
db = self .databases [0 ]["db" ]
@@ -415,7 +415,7 @@ def test_issue_364(self):
415
415
416
416
sql = "insert into issue364 (value_1, value_2) values (%s, %s)"
417
417
usql = u"insert into issue364 (value_1, value_2) values (%s, %s)"
418
- values = [b"\x00 \xff \x00 " , u"\xe4 \xf6 \xfc " ]
418
+ values = [pymysql . Binary ( b"\x00 \xff \x00 " ) , u"\xe4 \xf6 \xfc " ]
419
419
420
420
# test single insert and select
421
421
cur = conn .cursor ()
@@ -446,30 +446,32 @@ def test_issue_363(self):
446
446
"ENGINE=MyISAM default charset=utf8" )
447
447
448
448
cur = conn .cursor ()
449
- # FYI - not sure of 5.7.0 version
450
- if sys .version_info [0 :2 ] >= (3 ,2 ) and self .mysql_server_is (conn , (5 , 7 , 0 )):
449
+ query = ("INSERT INTO issue363 (id, geom) VALUES"
450
+ "(1998, GeomFromText('LINESTRING(1.1 1.1,2.2 2.2)'))" )
451
+ # From MySQL 5.7, ST_GeomFromText is added and GeomFromText is deprecated.
452
+ if self .mysql_server_is (conn , (5 , 7 , 0 )):
451
453
with self .assertWarns (pymysql .err .Warning ) as cm :
452
- cur .execute ("INSERT INTO issue363 (id, geom) VALUES ("
453
- "1998, GeomFromText('LINESTRING(1.1 1.1,2.2 2.2)'))" )
454
+ cur .execute (query )
454
455
else :
455
- cur .execute ("INSERT INTO issue363 (id, geom) VALUES ("
456
- "1998, GeomFromText('LINESTRING(1.1 1.1,2.2 2.2)'))" )
456
+ cur .execute (query )
457
457
458
458
# select WKT
459
+ query = "SELECT AsText(geom) FROM issue363"
459
460
if sys .version_info [0 :2 ] >= (3 ,2 ) and self .mysql_server_is (conn , (5 , 7 , 0 )):
460
461
with self .assertWarns (pymysql .err .Warning ) as cm :
461
- cur .execute ("SELECT AsText(geom) FROM issue363" )
462
+ cur .execute (query )
462
463
else :
463
- cur .execute ("SELECT AsText(geom) FROM issue363" )
464
+ cur .execute (query )
464
465
row = cur .fetchone ()
465
466
self .assertEqual (row , ("LINESTRING(1.1 1.1,2.2 2.2)" , ))
466
467
467
468
# select WKB
469
+ query = "SELECT AsBinary(geom) FROM issue363"
468
470
if sys .version_info [0 :2 ] >= (3 ,2 ) and self .mysql_server_is (conn , (5 , 7 , 0 )):
469
471
with self .assertWarns (pymysql .err .Warning ) as cm :
470
- cur .execute ("SELECT AsBinary(geom) FROM issue363" )
472
+ cur .execute (query )
471
473
else :
472
- cur .execute ("SELECT AsBinary(geom) FROM issue363" )
474
+ cur .execute (query )
473
475
row = cur .fetchone ()
474
476
self .assertEqual (row ,
475
477
(b"\x01 \x02 \x00 \x00 \x00 \x02 \x00 \x00 \x00 "
0 commit comments