Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #656 from frennkie/switch-project-sqlite-only
Browse files Browse the repository at this point in the history
Allow switching projects only on SQLite
  • Loading branch information
botherder committed Jul 4, 2020
2 parents a7469fa + b61faf1 commit f440ebb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions viper/core/database.py
Expand Up @@ -193,6 +193,8 @@ class Database:

def __init__(self):

self.supports_projects = False # currently only sqlite support projects

if cfg.database and cfg.database.connection:
self._connect_database(cfg.database.connection)
else:
Expand All @@ -218,6 +220,7 @@ def _connect_database(self, connection):
elif connection.startswith("postgresql"):
self.engine = create_engine(connection, connect_args={"sslmode": "disable"})
else:
self.supports_projects = True
db_path = os.path.join(__project__.get_path(), 'viper.db')
self.engine = create_engine('sqlite:///{0}'.format(db_path), poolclass=NullPool)

Expand Down
5 changes: 5 additions & 0 deletions viper/core/ui/cmd/projects.py
Expand Up @@ -63,6 +63,11 @@ def run(self, *args):

self.log("table", dict(header=["Project Name", "Creation Time", "Current"], rows=rows))
elif args.switch:
db = Database()
if not db.supports_projects:
self.log('info', "The database type you are using does not support projects")
return

if __sessions__.is_set():
__sessions__.close()
self.log("info", "Closed opened session")
Expand Down

0 comments on commit f440ebb

Please sign in to comment.