コード例 #1
0
ファイル: querier.py プロジェクト: BackupTheBerlios/maay-svn
 def __init__(self,
              host='',
              database='',
              user='',
              password='',
              connection=None):
     if connection is None:
         global IntegrityError
         dbapiMod = get_dbapi_compliant_module('mysql')
         IntegrityError = dbapiMod.IntegrityError
         try:
             connection = dbapiMod.connect(host=host,
                                           database=database,
                                           user=user,
                                           password=password,
                                           unicode=True)
             # FIXME: find a better way to perform this operation
             # the autodetection of the charset guesses latin-1 and
             # this obviously does not work with unicode
             connection.charset = 'utf-8'
         except dbapiMod.OperationalError:
             raise MaayAuthenticationError(
                 "Failed to authenticate user %r" % user)
         except Exception, e:
             traceback.print_exc()
             raise MaayAuthenticationError(
                 "Failed to authenticate user %r [%s]" % (user, e))
コード例 #2
0
ファイル: querier.py プロジェクト: BackupTheBerlios/maay-svn
 def __init__(self, host='', database='', user='', password='', connection=None):
     if connection is None:
         dbapiMod = get_dbapi_compliant_module('mysql')
         try:
             connection = dbapiMod.connect(host=host, database=database,
                                           user=user, password=password,
                                           unicode=True)
             # FIXME: find a better way to perform this operation
             # the autodetection of the charset guesses latin-1 and
             # this obviously does not work with unicode
             connection.charset='utf-8'
         except dbapiMod.OperationalError:
             raise MaayAuthenticationError("Failed to authenticate user %r"
                                           % user)
     self._cnx = connection
コード例 #3
0
ファイル: querier.py プロジェクト: BackupTheBerlios/maay-svn
 def __init__(self, host='', database='', user='', password='',
              connection=None):
     if connection is None:
         global IntegrityError
         dbapiMod = get_dbapi_compliant_module('mysql')
         IntegrityError = dbapiMod.IntegrityError
         try:
             connection = dbapiMod.connect(host=host, database=database,
                                           user=user, password=password,
                                           unicode=True)
             # FIXME: find a better way to perform this operation
             # the autodetection of the charset guesses latin-1 and
             # this obviously does not work with unicode
             connection.charset = 'UTF-8'
         except dbapiMod.OperationalError:
             raise MaayAuthenticationError("Failed to authenticate user %r"
                                           % user)
         except Exception, e:
             traceback.print_exc()
             raise MaayAuthenticationError(
                 "Failed to authenticate user %r [%s]" % (user, e))
コード例 #4
0
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
#     Public License for more details.
#
#     You should have received a copy of the GNU General Public License along
#     with this program; if not, write to the Free Software Foundation, Inc.,
#     59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.
"""Utility script to clean the database. This forces full reindexation
on the following indexer run
"""
__revision__ = '$Id$'

from maay.configuration import IndexerConfiguration
from logilab.common.db import get_dbapi_compliant_module

config = IndexerConfiguration()
config.load()

dbapiMod = get_dbapi_compliant_module('mysql')
connection = dbapiMod.connect(host=config.host,
                              database='maay',
                              user=config.user,
                              password=config.password,
                              unicode=True)

cursor = connection.cursor()
for table in ('nodes', 'document_providers', 'documents', 'document_scores',
              'words', 'files', 'node_interests'):
    nrows = cursor.execute('DELETE FROM %s;' % table)
    print "Deleted %d rows from table %s" % (nrows, table)
connection.commit()
コード例 #5
0
ファイル: cleandb.py プロジェクト: BackupTheBerlios/maay-svn
#     WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
#     Public License for more details.
#     
#     You should have received a copy of the GNU General Public License along
#     with this program; if not, write to the Free Software Foundation, Inc.,
#     59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.

"""Utility script to clean the database. This forces full reindexation
on the following indexer run
"""
__revision__ = '$Id$'

from maay.configuration import IndexerConfiguration
from logilab.common.db import get_dbapi_compliant_module

config = IndexerConfiguration()
config.load()


dbapiMod = get_dbapi_compliant_module('mysql')
connection = dbapiMod.connect(host=config.host, database='maay',
                              user=config.user, password=config.password,
                              unicode=True)

cursor = connection.cursor()
for table in ('nodes', 'document_providers', 'documents', 'document_scores', 'words', 'files', 'node_interests'):
    nrows = cursor.execute('DELETE FROM %s;' % table)
    print "Deleted %d rows from table %s" % (nrows, table)
connection.commit()
コード例 #6
0
ファイル: cleandb.py プロジェクト: BackupTheBerlios/maay-svn
#     WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
#     Public License for more details.
#
#     You should have received a copy of the GNU General Public License along
#     with this program; if not, write to the Free Software Foundation, Inc.,
#     59 Temple Place - Suite 330, Boston, MA 02111-1307 USA.

"""Utility script to clean the database. This forces full reindexation
on the following indexer run
"""
__revision__ = "$Id$"

from maay.indexer import IndexerConfiguration
from logilab.common.db import get_dbapi_compliant_module

config = IndexerConfiguration()
config.load()


dbapiMod = get_dbapi_compliant_module("mysql")
connection = dbapiMod.connect(
    host=config.host, database="maay", user=config.user, password=config.password, unicode=True
)

cursor = connection.cursor()
for table in ("nodes", "document_providers", "documents", "document_scores", "words", "files", "node_interests"):
    nrows = cursor.execute("DELETE FROM %s;" % table)
    print "Deleted %d rows from table %s" % (nrows, table)
connection.commit()