diff --git a/mutalyzer/Db.py b/mutalyzer/Db.py deleted file mode 100644 index 376221d6480c9871648b67c0e04e73c1b832e943..0000000000000000000000000000000000000000 --- a/mutalyzer/Db.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/python - -""" -Module for database access. -The Db class is a superclass of the rest of the classes and should not be -used as such. The superclass mainly consists of a wrapper for SQL -statements. - -@requires: MySQLdb -@requires: types -@requires: time -@requires: os -""" - -#Public classes: -# - Db ; Log in to a database and keep it open for queries. -# - Mapping ; Mapping of transcripts and genes. -# - Cache ; Cache administration. -# - Batch ; Batch checker. - - -import types -import warnings - -import MySQLdb - -from mutalyzer import util -from mutalyzer.config import settings - - -# -# Note that compound queries are split into single queries because of a bug -# in MySQLdb. The functions load_Update(), merge_cdsUpdates() and -# merge_Update (search for MYSQL_BUG in this file) are affected and may be -# rewritten when this bug is fixed. -# - -class Db(): - """ - Query the database server (and lazily keep a connection open to it). - - This class is subclassed below to create specific interfaces to the - database. - """ - def __init__(self, database, user, host): - """ - Create an interface to the database. - - @arg database: Name of the database to use. - @type database: str - @arg user: User name for the database. - @type user: str - @arg host: Host name for the database. - @type host: str - """ - self._database = database - self._user = user - self._host = host - - # The connection to the database server is created lazily in the query - # method. - self._connection = None - #__init__ - - def _connect(self): - """ - Connect to the database server. - - Note: We would like to automatically reconnect to the database server. - This is especially useful for long-running processes such as the - batch deamon, which would otherwise loose their connection on an - event such as restarting the database server. - The MySQL client libraries provide a reconnect option, but this - is unfortunately not implemented in (most versions of) the Python - MySQLdb module. - Therefore we manually implement automatic reconnects in the query - method. - Also see Trac ticket #91. - """ - self._connection = MySQLdb.connect( - user=self._user, db=self._database, host=self._host) - #_connect - - def query(self, statement): - """ - Query the database. - - @arg statement: The statement that is to be queried - @type statement: tuple (string, (args)) - - @return: The result of the query - @rtype: list - """ - - # Convert the arguments to a tuple. - if type(statement[1]) != types.TupleType : - args = statement[1], - else : - args = statement[1] - - # Escape the input to prevent SQL injections. - escaped_args = [] - if args != (None,) : # Don't escape the empty string. - for i in args : - if i : - if type(i) in [types.StringType, types.UnicodeType]: - escaped_args.append(MySQLdb.escape_string(str(i))) - else : - escaped_args.append(i) - else : - escaped_args.append(None) - #if - - # Do the query, but first connect to the database server if needed. - # This makes sure lost connections are re-created automatically (e.g. - # in case the server was restarted for maintenance). - try: - cursor = self._connection.cursor() - cursor.execute(statement[0], tuple(escaped_args)) - except (AttributeError, MySQLdb.OperationalError): - self._connect() - cursor = self._connection.cursor() - cursor.execute(statement[0], tuple(escaped_args)) - - result = cursor.fetchall() - cursor.close() - - return result - #query -#Db diff --git a/mutalyzer/GenRecord.py b/mutalyzer/GenRecord.py index 917d056c5aa71d652217008b4c4042cf061d4ff8..b30ed80060bb3135f28650bb9bfae4bbf1f30b61 100644 --- a/mutalyzer/GenRecord.py +++ b/mutalyzer/GenRecord.py @@ -6,7 +6,6 @@ search for them each time. @requires: Crossmap @requires: Bio -@requires: Db """ # Public classes: # - PList ; Store a general location and a list of splice sites. @@ -20,7 +19,6 @@ import Bio from mutalyzer import util from mutalyzer import Crossmap -from mutalyzer import Db SPLICE_ALARM = 2 diff --git a/mutalyzer/Retriever.py b/mutalyzer/Retriever.py index 7c224e4894a6052f6c6d71aec980e36fe24175a4..d2d01c5da0486188817e0bedf94f4eb42b785486 100644 --- a/mutalyzer/Retriever.py +++ b/mutalyzer/Retriever.py @@ -63,13 +63,7 @@ class Retriever(object) : - uploadrecord(raw_data) ; Let someone upload a GenBank file. - loadrecord(identifier) ; Load a record, store it in the cache, manage the cache and return the record. - - Inherited methods from Db.Output: - - WarningMsg(filename, message) ; Print a warning message. - - ErrorMsg(filename, message) ; Print an error message and log it. - - LogMsg(filename, message) ; Log a message. """ - def __init__(self, output) : """ Use variables from the configuration file for some simple diff --git a/mutalyzer/config/default_settings.py b/mutalyzer/config/default_settings.py index 108ad84dacd5cd67dd03dd069f1082691f269623..d7cd74577bdb4b6044eae3d7e164a09aa9333e8e 100644 --- a/mutalyzer/config/default_settings.py +++ b/mutalyzer/config/default_settings.py @@ -33,15 +33,6 @@ REDIS_URI = None # Database connection URI (can be any SQLAlchemy connection URI). DATABASE_URI = 'sqlite://' -# Host name for local MySQL databases. -MYSQL_HOST = 'localhost' - -# User for local MySQL databases. -MYSQL_USER = 'mutalyzer' - -# Local MySQL database name. -MYSQL_DATABASE = 'mutalyzer' - # Default genome assembly (by name or alias). DEFAULT_ASSEMBLY = 'hg19' diff --git a/mutalyzer/mapping.py b/mutalyzer/mapping.py index c10c15456367caf2d3787190ca6df7851b550997..7bc9813b82ebec938c1416dc08e9408f8382cad0 100644 --- a/mutalyzer/mapping.py +++ b/mutalyzer/mapping.py @@ -18,7 +18,6 @@ import MySQLdb from mutalyzer.db.models import Chromosome, TranscriptMapping from mutalyzer.grammar import Grammar -from mutalyzer import Db from mutalyzer import Crossmap from mutalyzer import Retriever from mutalyzer.models import SoapMessage, Mapping, Transcript diff --git a/mutalyzer/services/rpc.py b/mutalyzer/services/rpc.py index 86cc0a161520fd1815d54f8559c19b5f633320db..ced3405e677141dff90ea404e24e09ab037b21ce 100644 --- a/mutalyzer/services/rpc.py +++ b/mutalyzer/services/rpc.py @@ -30,7 +30,6 @@ from mutalyzer.grammar import Grammar from mutalyzer.sync import CacheSync from mutalyzer import stats from mutalyzer import variantchecker -from mutalyzer import Db from mutalyzer.mapping import Converter from mutalyzer import File from mutalyzer import Retriever diff --git a/mutalyzer/website.py b/mutalyzer/website.py index 63dd324782f55eace5a0d6caf70b2dc2e5ec23d0..266185fdcd66edaed55f1dfbc22e2fc2bf9ce7c3 100644 --- a/mutalyzer/website.py +++ b/mutalyzer/website.py @@ -42,7 +42,6 @@ from mutalyzer.services import soap from mutalyzer import variantchecker from mutalyzer.output import Output from mutalyzer.mapping import Converter -from mutalyzer import Db from mutalyzer import Scheduler from mutalyzer import Retriever from mutalyzer import File diff --git a/tests/test_services_soap.py b/tests/test_services_soap.py index ed5b3e6bfed96b089b16e3b925cb470e9694d3cd..13d0335c3e025413105dec6e614d475dce60c456 100644 --- a/tests/test_services_soap.py +++ b/tests/test_services_soap.py @@ -15,7 +15,6 @@ from spyne.model.fault import Fault from suds.client import Client import mutalyzer -from mutalyzer import Db from mutalyzer.output import Output from mutalyzer.services.soap import application from mutalyzer.sync import CacheSync