Commit 1beb6f80 authored by Lars Kruse's avatar Lars Kruse
Browse files

feat(database): add support for sqlite database

An sqlite database is much easier to setup for simple local deployments
and specifically for test automation.
parent d041f86c
Pipeline #1107 passed with stage
in 2 minutes and 4 seconds
...@@ -108,15 +108,19 @@ class AuraConfig: ...@@ -108,15 +108,19 @@ class AuraConfig:
Retrieves the database connection string. Retrieves the database connection string.
""" """
db_name = str(self.get("db_name")) db_name = str(self.get("db_name"))
db_user = str(self.get("db_user"))
db_pass = str(self.get("db_pass"))
db_host = str(self.get("db_host"))
db_type = str(self.get("db_type")) db_type = str(self.get("db_type"))
db_charset = self.get("db_charset", "utf8") if db_type in {"mysql", "postgresql"}:
if db_type == "mysql": db_user = str(self.get("db_user"))
return "mysql://" + db_user + ":" + db_pass + "@" + db_host + "/" + db_name + "?charset=" + db_charset db_pass = str(self.get("db_pass"))
elif db_type == "postgresql": db_host = str(self.get("db_host"))
return f"postgresql+psycopg2://{db_user}:{db_pass}@{db_host}/{db_name}?client_encoding={db_charset}" db_charset = self.get("db_charset", "utf8")
if db_type == "mysql":
return f"mysql://{db_user}:{db_pass}@{db_host}/{db_name}?charset={db_charset}"
else:
return f"postgresql+psycopg2://{db_user}:{db_pass}@{db_host}/{db_name}?client_encoding={db_charset}"
elif db_type == "sqlite":
# "db_name" is expected to be either a relative or an absolute path to the sqlite file
return f"sqlite:///{db_name}"
else: else:
return f"Error: invalid database type '{db_type}'" return f"Error: invalid database type '{db_type}'"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment