Commits

Alexander Solovyov committed 95108a4

fix dbshell command

  • Participants
  • Parent commits 509aa0c

Comments (0)

Files changed (1)

File svarga/core/commands.py

 def dbshell():
     '''Run command-line client for the current database
     '''
+    from amalgam.backends.sqla import SABackend
 
-    cmd, conf = DBCOMMANDS[env.sqla.engine.name]
+    if 'default' not in db.databases:
+        print 'You have no default database defined'
+        return 1
+
+    if not isinstance(db.default, SABackend):
+        print 'Your default db backend is not SQLAlchemy'
+        print 'No idea how to get a shell to it'
+        return 1
+
+    cmd, conf = DBCOMMANDS[db.default.engine.name]
     args = [cmd]
 
     for o in ['username', 'password', 'host', 'port', 'database']:
-        value = getattr(env.sqla.engine.url, o)
+        value = getattr(db.default.engine.url, o)
         if value:
             src = conf.get(o, '--%s=%%s' % o) # --option=value
             if src: