replaced third-party library python-mysql with python pymysql, http://code.google.com/p/pymysql/ (MIT license)

This commit is contained in:
Bernardo Damele 2011-06-22 13:31:07 +00:00
parent e76cb19e35
commit 1cb12ea659
5 changed files with 15 additions and 15 deletions

View File

@ -57,7 +57,7 @@ for the database management system that you are going to attack:
<item>Firebird: <htmlurl name="python-kinterbasdb" url="http://kinterbasdb.sourceforge.net/">.
<item>Microsoft Access: <htmlurl name="python-pyodbc" url="http://pyodbc.googlecode.com/">.
<item>Microsoft SQL Server: <htmlurl name="python-pymssql" url="http://pymssql.sourceforge.net/">.
<item>MySQL: <htmlurl name="python-mysqldb" url="http://mysql-python.sourceforge.net/">.
<item>MySQL: <htmlurl name="python pymysql" url="http://code.google.com/p/pymysql/">.
<item>Oracle: <htmlurl name="python cx_Oracle" url="http://cx-oracle.sourceforge.net/">.
<item>PostgreSQL: <htmlurl name="python-psycopg2" url="http://initd.org/psycopg/">.
<item>SQLite: <htmlurl name="python-pysqlite2" url="http://pysqlite.googlecode.com/">.

View File

@ -1036,7 +1036,7 @@ def parseTargetDirect():
raise sqlmapMissingDependence, errMsg
elif dbmsName == DBMS.MYSQL:
import MySQLdb
import pymysql
elif dbmsName == DBMS.PGSQL:
import psycopg2
elif dbmsName == DBMS.ORACLE:

View File

@ -159,7 +159,7 @@ SUPPORTED_DBMS = MSSQL_ALIASES + MYSQL_ALIASES + PGSQL_ALIASES + ORACLE_ALIASES
SUPPORTED_OS = ( "linux", "windows" )
DBMS_DICT = { DBMS.MSSQL: [MSSQL_ALIASES, "python-pymssql", "http://pymssql.sourceforge.net/"],
DBMS.MYSQL: [MYSQL_ALIASES, "python-mysqldb", "http://mysql-python.sourceforge.net/"],
DBMS.MYSQL: [MYSQL_ALIASES, "python pymysql", "http://code.google.com/p/pymysql/"],
DBMS.PGSQL: [PGSQL_ALIASES, "python-psycopg2", "http://initd.org/psycopg/"],
DBMS.ORACLE: [ORACLE_ALIASES, "python cx_Oracle", "http://cx-oracle.sourceforge.net/"],
DBMS.SQLITE: [SQLITE_ALIASES, "python-pysqlite2", "http://pysqlite.googlecode.com/"],

View File

@ -32,7 +32,7 @@ def checkDependencies():
warnMsg += "Download from %s" % data[2]
logger.warn(warnMsg)
elif dbmsName == DBMS.MYSQL:
import MySQLdb
import pymysql
elif dbmsName == DBMS.PGSQL:
import psycopg2
elif dbmsName == DBMS.ORACLE:

View File

@ -8,7 +8,7 @@ See the file 'doc/COPYING' for copying permission
"""
try:
import MySQLdb
import pymysql
except ImportError, _:
pass
@ -20,11 +20,11 @@ from plugins.generic.connector import Connector as GenericConnector
class Connector(GenericConnector):
"""
Homepage: http://mysql-python.sourceforge.net/
User guide: http://mysql-python.sourceforge.net/MySQLdb.html
API: http://mysql-python.sourceforge.net/MySQLdb-1.2.2/
Debian package: python-mysqldb
License: GPL
Homepage: http://code.google.com/p/pymysql/
User guide: http://code.google.com/p/pymysql/
API: http://code.google.com/p/pymysql/
Debian package: <none>
License: MIT
Possible connectors: http://wiki.python.org/moin/MySQL
"""
@ -36,8 +36,8 @@ class Connector(GenericConnector):
self.initConnection()
try:
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)
except MySQLdb.OperationalError, msg:
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)
except pymysql.OperationalError, msg:
raise sqlmapConnectionException, msg[1]
self.setCursor()
@ -46,16 +46,16 @@ class Connector(GenericConnector):
def fetchall(self):
try:
return self.cursor.fetchall()
except MySQLdb.ProgrammingError, msg:
except pymysql.ProgrammingError, msg:
logger.warn(msg[1])
return None
def execute(self, query):
try:
self.cursor.execute(query)
except (MySQLdb.OperationalError, MySQLdb.ProgrammingError), msg:
except (pymysql.OperationalError, pymysql.ProgrammingError), msg:
logger.warn(msg[1])
except MySQLdb.InternalError, msg:
except pymysql.InternalError, msg:
raise sqlmapConnectionException, msg[1]
self.connector.commit()