Various bug fixes.

This commit is contained in:
lwark
2024-07-29 10:39:46 -05:00
parent 9a455647ce
commit 7a5b9533cc
3 changed files with 12 additions and 6 deletions

View File

@@ -123,6 +123,7 @@ This is meant to import .xslx files created from the Design & Analysis Software
6. Install dependencies: ```pip install -r requirements.txt``` 6. Install dependencies: ```pip install -r requirements.txt```
## Database: ## Database:
*If using a pre-existing database, skip this.*
1. Copy 'alembic_default.ini' to 'alembic.ini' in the same folder. 1. Copy 'alembic_default.ini' to 'alembic.ini' in the same folder.
2. Open 'alembic.ini' and edit 'sqlalchemy.url' to the desired path of the database. 2. Open 'alembic.ini' and edit 'sqlalchemy.url' to the desired path of the database.

Binary file not shown.

View File

@@ -443,19 +443,23 @@ class Settings(BaseSettings, extra="allow"):
if 'pytest' in sys.modules: if 'pytest' in sys.modules:
output = dict(power_users=['lwark', 'styson', 'ruwang']) output = dict(power_users=['lwark', 'styson', 'ruwang'])
else: else:
print(f"Hello from database settings getter.")
# session = Session(create_engine(f"sqlite:///{db_path}")) # session = Session(create_engine(f"sqlite:///{db_path}"))
logger.debug(self.__dict__) # print(self.__dict__)
session = self.database_session session = self.database_session
metadata = MetaData() metadata = MetaData()
# print(self.database_session.get_bind())
try: try:
tables = metadata.reflect(bind=session.get_bind()).tables.keys() metadata.reflect(bind=session.get_bind())
except AttributeError: except AttributeError as e:
print(f"Error getting tables: {e}")
return return
if "_configitem" not in tables: if "_configitem" not in metadata.tables.keys():
print(f"Couldn't find _configitems in {metadata.tables.keys()}.")
return return
config_items = session.execute(text("SELECT * FROM _configitem")).all() config_items = session.execute(text("SELECT * FROM _configitem")).all()
session.close() # print(f"Config: {pprint.pprint(config_items)}")
# print(config_items)
output = {} output = {}
for item in config_items: for item in config_items:
try: try:
@@ -467,6 +471,7 @@ class Settings(BaseSettings, extra="allow"):
if not hasattr(self, k): if not hasattr(self, k):
self.__setattr__(k, v) self.__setattr__(k, v)
@classmethod @classmethod
def get_alembic_db_path(cls, alembic_path, mode=Literal['path', 'schema', 'user', 'pass']) -> Path | str: def get_alembic_db_path(cls, alembic_path, mode=Literal['path', 'schema', 'user', 'pass']) -> Path | str:
c = ConfigParser() c = ConfigParser()