Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency on mysqldb in wmgr (DM-3947) #6

Merged
merged 1 commit into from
Sep 29, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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(conn, code):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has portability issues, I believe code above is not a portable sqlalchemy thing. As I mentioned in qserv branch this is closely related to what Brian wants to do for dax_dbserv, maybe we should merge this together with Brian's development.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brianv0 , how would you like to proceed?

"""
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())