Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1cb12ea

Browse files
committed
replaced third-party library python-mysql with python pymysql, http://code.google.com/p/pymysql/ (MIT license)
1 parent e76cb19 commit 1cb12ea

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

doc/README.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ for the database management system that you are going to attack:
5757
<item>Firebird: <htmlurl name="python-kinterbasdb" url="http://kinterbasdb.sourceforge.net/">.
5858
<item>Microsoft Access: <htmlurl name="python-pyodbc" url="http://pyodbc.googlecode.com/">.
5959
<item>Microsoft SQL Server: <htmlurl name="python-pymssql" url="http://pymssql.sourceforge.net/">.
60-
<item>MySQL: <htmlurl name="python-mysqldb" url="http://mysql-python.sourceforge.net/">.
60+
<item>MySQL: <htmlurl name="python pymysql" url="http://code.google.com/p/pymysql/">.
6161
<item>Oracle: <htmlurl name="python cx_Oracle" url="http://cx-oracle.sourceforge.net/">.
6262
<item>PostgreSQL: <htmlurl name="python-psycopg2" url="http://initd.org/psycopg/">.
6363
<item>SQLite: <htmlurl name="python-pysqlite2" url="http://pysqlite.googlecode.com/">.

lib/core/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ def parseTargetDirect():
10361036
raise sqlmapMissingDependence, errMsg
10371037

10381038
elif dbmsName == DBMS.MYSQL:
1039-
import MySQLdb
1039+
import pymysql
10401040
elif dbmsName == DBMS.PGSQL:
10411041
import psycopg2
10421042
elif dbmsName == DBMS.ORACLE:

lib/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
SUPPORTED_OS = ( "linux", "windows" )
160160

161161
DBMS_DICT = { DBMS.MSSQL: [MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"],
162-
DBMS.MYSQL: [MYSQL_ALIASES, "python-mysqldb", "http://mysql-python.sourceforge.net/"],
162+
DBMS.MYSQL: [MYSQL_ALIASES, "python pymysql", "http://code.google.com/p/pymysql/"],
163163
DBMS.PGSQL: [PGSQL_ALIASES, "python-psycopg2", "http://initd.org/psycopg/"],
164164
DBMS.ORACLE: [ORACLE_ALIASES, "python cx_Oracle", "http://cx-oracle.sourceforge.net/"],
165165
DBMS.SQLITE: [SQLITE_ALIASES, "python-pysqlite2", "http://pysqlite.googlecode.com/"],

lib/utils/deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def checkDependencies():
3232
warnMsg += "Download from %s" % data[2]
3333
logger.warn(warnMsg)
3434
elif dbmsName == DBMS.MYSQL:
35-
import MySQLdb
35+
import pymysql
3636
elif dbmsName == DBMS.PGSQL:
3737
import psycopg2
3838
elif dbmsName == DBMS.ORACLE:

plugins/dbms/mysql/connector.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
try:
11-
import MySQLdb
11+
import pymysql
1212
except ImportError, _:
1313
pass
1414

@@ -20,11 +20,11 @@
2020

2121
class Connector(GenericConnector):
2222
"""
23-
Homepage: http://mysql-python.sourceforge.net/
24-
User guide: http://mysql-python.sourceforge.net/MySQLdb.html
25-
API: http://mysql-python.sourceforge.net/MySQLdb-1.2.2/
26-
Debian package: python-mysqldb
27-
License: GPL
23+
Homepage: http://code.google.com/p/pymysql/
24+
User guide: http://code.google.com/p/pymysql/
25+
API: http://code.google.com/p/pymysql/
26+
Debian package: <none>
27+
License: MIT
2828
2929
Possible connectors: http://wiki.python.org/moin/MySQL
3030
"""
@@ -36,8 +36,8 @@ def connect(self):
3636
self.initConnection()
3737

3838
try:
39-
self.connector = MySQLdb.connect(host=self.hostname, user=self.user, passwd=self.password, db=self.db, port=self.port, connect_timeout=conf.timeout, use_unicode=True)
40-
except MySQLdb.OperationalError, msg:
39+
self.connector = pymysql.connect(host=self.hostname, user=self.user, passwd=self.password, db=self.db, port=self.port, connect_timeout=conf.timeout, use_unicode=True)
40+
except pymysql.OperationalError, msg:
4141
raise sqlmapConnectionException, msg[1]
4242

4343
self.setCursor()
@@ -46,16 +46,16 @@ def connect(self):
4646
def fetchall(self):
4747
try:
4848
return self.cursor.fetchall()
49-
except MySQLdb.ProgrammingError, msg:
49+
except pymysql.ProgrammingError, msg:
5050
logger.warn(msg[1])
5151
return None
5252

5353
def execute(self, query):
5454
try:
5555
self.cursor.execute(query)
56-
except (MySQLdb.OperationalError, MySQLdb.ProgrammingError), msg:
56+
except (pymysql.OperationalError, pymysql.ProgrammingError), msg:
5757
logger.warn(msg[1])
58-
except MySQLdb.InternalError, msg:
58+
except pymysql.InternalError, msg:
5959
raise sqlmapConnectionException, msg[1]
6060

6161
self.connector.commit()

0 commit comments

Comments
 (0)