Skip to content

Commit

Permalink
[Controller] Abstract db client & move functions from Base to DB clie…
Browse files Browse the repository at this point in the history
…nt (#26)

* [Controller] Abstract db client & move to, from, merge orm from base schema to sqlclient

* requested changes

* remove object casting abstract methods from abstract client
  • Loading branch information
yonishelach authored Oct 15, 2024
1 parent c13c4e9 commit 60c7a30
Show file tree
Hide file tree
Showing 12 changed files with 876 additions and 107 deletions.
2 changes: 1 addition & 1 deletion controller/src/controller/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def initdb():
"""
click.echo("Running Init DB")
db_session = client.get_db_session()
client.create_tables(True)
client.create_database(True)

# Create admin user:
click.echo("Creating admin user")
Expand Down
8 changes: 5 additions & 3 deletions controller/src/controller/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@
class CtrlConfig(BaseModel):
"""Configuration for the agent."""

verbose: bool = True
log_level: str = "DEBUG"
# SQL Database
# database kwargs:
db: dict[str, str] = {
"db_url": default_db_path,
"verbose": True,
}
db_type: str = "sql"
sql_connection_str: str = default_db_path
application_url: str = "http://localhost:8000"

def print(self):
Expand Down
12 changes: 10 additions & 2 deletions controller/src/controller/db/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from enum import Enum

from controller.config import config
from controller.db.sqlclient import SqlClient

client = None


class DatabaseType(str, Enum):
SQL = "sql"


if config.db_type == "sql":
client = SqlClient(config.sql_connection_str, verbose=config.verbose)
from controller.db.sql import SqlClient

client = SqlClient(**config.db)
Loading

0 comments on commit 60c7a30

Please sign in to comment.