Prevent flush from creating cursor without con
MysqlRed.flush() tried to create a cursor in any case. If there was no connection (because the subclasses haven't been instantiated an oursql Error occured. Instead, check before if there is a connection and otherwise raise an Error Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=75 FS#75] Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=75 FS#75]
This commit is contained in:
17
mysqlred.py
17
mysqlred.py
@@ -92,6 +92,9 @@ class MysqlRed:
|
|||||||
"""
|
"""
|
||||||
Run cached querys
|
Run cached querys
|
||||||
"""
|
"""
|
||||||
|
if not cls.connection:
|
||||||
|
raise MysqlRedConnectionError( "No connection exists!" )
|
||||||
|
|
||||||
cursor = cls.connection.cursor()
|
cursor = cls.connection.cursor()
|
||||||
|
|
||||||
# Execute insert query
|
# Execute insert query
|
||||||
@@ -307,3 +310,17 @@ article7 ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );'
|
|||||||
break
|
break
|
||||||
for row in res:
|
for row in res:
|
||||||
yield row
|
yield row
|
||||||
|
|
||||||
|
|
||||||
|
class MysqlRedError(Exception):
|
||||||
|
"""
|
||||||
|
Basic Exception class for this module
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MysqlRedConnectionError(MysqlRedError):
|
||||||
|
"""
|
||||||
|
Raised if there are Errors with Mysql-Connections
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class DiscussionParserBot(
|
|||||||
reddisc=red_page.page.title() ) )
|
reddisc=red_page.page.title() ) )
|
||||||
else:
|
else:
|
||||||
jogobot.output(
|
jogobot.output(
|
||||||
"\03{red} Page [[{reddisc}]], ".format(
|
"\03{red}" + "Page [[{reddisc}]], ".format(
|
||||||
reddisc=red_page.page.title() ) +
|
reddisc=red_page.page.title() ) +
|
||||||
"containing no redfam, parsed!",
|
"containing no redfam, parsed!",
|
||||||
"WARNING" )
|
"WARNING" )
|
||||||
|
|||||||
Reference in New Issue
Block a user