Skip to content

Commit

Permalink
mysql-specific field_type decoding moved to db
Browse files Browse the repository at this point in the history
  • Loading branch information
jbecla committed Sep 25, 2015
1 parent 01aa897 commit 9595059
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions python/lsst/db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from sqlalchemy.sql import text
from sqlalchemy.inspection import inspect

from MySQLdb.constants import FIELD_TYPE


# MySQL errors that we are catching
Expand Down Expand Up @@ -372,3 +373,17 @@ def userExists(conn, userName, hostName):
(userName, hostName)).scalar() == 1
else:
raise NoSuchModuleError(conn.engine.url.get_backend_name())


#### Unclassified functions ########################################################
def typeCode2Name(code):
"""
Convert type code to type name, returns None if there is no mapping.
"""
if conn.engine.url.get_backend_name() == "mysql":
for name in dir(FIELD_TYPE):
if getattr(FIELD_TYPE, name) == code:
return name
return None
else:
raise NoSuchModuleError(conn.engine.url.get_backend_name())

0 comments on commit 9595059

Please sign in to comment.