4 from wizard import shell
6 # We're going to use sqlalchemy.engine.url.URL as our database
7 # info intermediate object
10 """Convenience method for connecting to a MySQL database."""
11 engine = sqlalchemy.create_engine(url)
12 meta = sqlalchemy.MetaData()
19 If the URL has a database name but no other values, it will
20 use the global configuration, and then try the database name.
27 # omitted port and query
28 if any((url.host, url.username, url.password)):
29 # don't try for defaults if a few of these were set
32 if url.driver == "mysql":
34 url.host, url.username, url.password = shell.Shell().eval("/mit/scripts/sql/bin/get-password").split()
36 except shell.CallError:
38 dsn = os.getenv("WIZARD_DSN")
40 url = sqlalchemy.engine.url.make_url(dsn)
41 url.database = old_url.database