refs #0 The root commit.

This commit is contained in:
sbps-test user
2023-09-13 20:37:14 +03:00
commit 10eb607154
66 changed files with 1643 additions and 0 deletions

27
back/core/field.py Normal file
View File

@@ -0,0 +1,27 @@
from sqlalchemy import Column, Integer, String
def get_field(field_attrs: dict) -> Column:
"""
Construct sqlalchemy field using dictionary with field attributes.
Returns the sqlalchemy column.
:param field_attrs: The dictionary with field attributes.
"""
column_attrs = {}
for key, value in field_attrs.items():
if key == "type":
match value:
case "str":
column_attrs["type_"] = String
case "int":
column_attrs["type_"] = Integer
case "file":
column_attrs["type_"] = String
elif key == "nullable":
column_attrs["nullable"] = value
return Column(**column_attrs)