NOT WORKING Cache SQL querys to reduce amount of querys
This commit is contained in:
28
mysqlred.py
28
mysqlred.py
@@ -80,6 +80,13 @@ class MysqlRedPage( MysqlRed ):
|
||||
MySQL-db Interface for handling querys for RedPages
|
||||
"""
|
||||
|
||||
# Class variables for storing cached querys
|
||||
__cached_update = []
|
||||
__cached_insert_data = []
|
||||
__insert_query = 'INSERT INTO `red_pages` \
|
||||
( page_id, page_title, rev_id, status ) \
|
||||
VALUES ( ?, ?, ?, ? );'
|
||||
|
||||
def __init__( self, page_id ):
|
||||
"""
|
||||
Creates a new instance, runs __init__ of parent class
|
||||
@@ -124,23 +131,12 @@ class MysqlRedPage( MysqlRed ):
|
||||
@param int status Page parsing status
|
||||
"""
|
||||
|
||||
cursor = type( self ).connection.cursor()
|
||||
__cached_insert_data.apend( ( self.__page_id, page_title,
|
||||
rev_id, status ) )
|
||||
|
||||
if not page_title:
|
||||
page_title = self.data[ 'page_title' ]
|
||||
if not rev_id:
|
||||
rev_id = self.data[ 'rev_id' ]
|
||||
|
||||
query = 'INSERT INTO `red_pages` \
|
||||
( page_id, page_title, rev_id, status ) \
|
||||
VALUES ( ?, ?, ?, ? );'
|
||||
data = ( self.__page_id, page_title, rev_id, status )
|
||||
|
||||
cursor.execute( query, data)
|
||||
|
||||
type( self ).connection.commit()
|
||||
|
||||
self.data = self.get_page()
|
||||
# Manualy construct self.data dict
|
||||
self.data = { 'page_id' : self.__page_id, 'rev_id' : rev_id,
|
||||
'page_title' : page_title, 'status' : status }
|
||||
|
||||
def update_page( self, rev_id=None, page_title=None, status=0 ):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user