Minor changes and updates for AAPOR with Confex

This commit is contained in:
Scott Idem
2024-04-25 16:16:15 -04:00
parent a41f4f0a33
commit 0745ac2fd4
4 changed files with 18 additions and 10 deletions

View File

@@ -4,5 +4,9 @@
"path": "." "path": "."
} }
], ],
"settings": {} "settings": {
"cSpell.words": [
"poolclass"
]
}
} }

View File

@@ -6,6 +6,7 @@ from app.log import log, logging, logger_reset
from sqlalchemy import create_engine, text, Time from sqlalchemy import create_engine, text, Time
from sqlalchemy.exc import IntegrityError, OperationalError, ProgrammingError from sqlalchemy.exc import IntegrityError, OperationalError, ProgrammingError
from sqlalchemy.pool import NullPool
db_uri = settings.SQLALCHEMY_DB_URI db_uri = settings.SQLALCHEMY_DB_URI
@@ -15,10 +16,12 @@ db_uri = settings.SQLALCHEMY_DB_URI
# log.setLevel(logging.INFO) # log.setLevel(logging.INFO)
connection_string = db_uri connection_string = db_uri
engine = create_engine(url=connection_string, pool_size=5, max_overflow=15, pool_recycle=settings.DB['pool_recycle'], pool_pre_ping=True, echo=False, echo_pool=True, isolation_level='READ UNCOMMITTED', connect_args={'connect_timeout': settings.DB['connect_timeout']}) engine = create_engine(url=connection_string, poolclass=NullPool, echo=False, isolation_level='READ COMMITTED', connect_args={'connect_timeout': settings.DB['connect_timeout']})
# engine = create_engine(url=connection_string, pool_size=5, max_overflow=15, pool_recycle=settings.DB['pool_recycle'], pool_pre_ping=True, echo=False, echo_pool=True, isolation_level='READ UNCOMMITTED', connect_args={'connect_timeout': settings.DB['connect_timeout']})
# NOTE: The default isolation_level is 'REPEATABLE READ'. This can sometimes not show updated data. # NOTE: The default isolation_level is 'REPEATABLE READ'. This can sometimes not show updated data.
# NOTE: The "echo" set to True option shows the SQL queries. # NOTE: The "echo" set to True option shows the SQL queries.
# NOTE: Switching from READ COMMITTED to READ UNCOMMITTED (or REPEATABLE READ). Testing started 2024-04-23 # NOTE: Switching from READ COMMITTED to READ UNCOMMITTED (or REPEATABLE READ). Testing started 2024-04-23
# levels: "REPEATABLE READ" "READ COMMITTED" "READ UNCOMMITTED" "SERIALIZABLE"
log.info('DB SQL trying to connect...') log.info('DB SQL trying to connect...')
try: try:
@@ -60,7 +63,8 @@ def sql_connect(
settings.SQLALCHEMY_DB_URI = 'mysql://'+DB['username']+':'+DB['password']+'@'+DB['server']+'/'+DB['name'] settings.SQLALCHEMY_DB_URI = 'mysql://'+DB['username']+':'+DB['password']+'@'+DB['server']+'/'+DB['name']
log.debug(settings.DB) log.debug(settings.DB)
new_engine = create_engine(url=settings.SQLALCHEMY_DB_URI, pool_size=5, max_overflow=15, pool_recycle=settings.DB['pool_recycle'], pool_pre_ping=True, echo=False, echo_pool=True, isolation_level='READ UNCOMMITTED', connect_args={'connect_timeout': settings.DB['connect_timeout']}) new_engine = create_engine(url=settings.SQLALCHEMY_DB_URI, poolclass=NullPool, echo=False, isolation_level='READ UNCOMMITTED', connect_args={'connect_timeout': settings.DB['connect_timeout']})
# new_engine = create_engine(url=settings.SQLALCHEMY_DB_URI, pool_size=5, max_overflow=15, pool_recycle=settings.DB['pool_recycle'], pool_pre_ping=True, echo=False, echo_pool=True, isolation_level='READ UNCOMMITTED', connect_args={'connect_timeout': settings.DB['connect_timeout']})
current_db.engine = new_engine current_db.engine = new_engine
log.info(f'Created and connected to database: {settings.SQLALCHEMY_DB_URI}') log.info(f'Created and connected to database: {settings.SQLALCHEMY_DB_URI}')

View File

@@ -10,9 +10,6 @@ from functools import lru_cache
from pydantic import BaseModel, EmailStr, Field from pydantic import BaseModel, EmailStr, Field
from typing import Dict, List, Optional, Set, Union from typing import Dict, List, Optional, Set, Union
# from sqlalchemy import create_engine, text
# from sqlalchemy.exc import IntegrityError, OperationalError
from . import config from . import config
# from app.lib_general import common_route_params, Common_Route_Params # from app.lib_general import common_route_params, Common_Route_Params
from app.log import log, logging from app.log import log, logging

View File

@@ -27,13 +27,14 @@ router = APIRouter()
# ### BEGIN ### API Confex ### import_event_session_list() ### # ### BEGIN ### API Confex ### import_event_session_list() ###
# Updated 2023-04-1 # processing time: 156 records @ 1457 seconds (sessions, locations, presentations, presenters, files)
# Updated 2024-04-25
@router.get('/event/{e_confex_event_id}/import_reg', response_model=Resp_Body_Base) @router.get('/event/{e_confex_event_id}/import_reg', response_model=Resp_Body_Base)
async def import_event_session_list( async def import_event_session_list(
e_confex_event_id: str = Query(..., min_length=5, max_length=22), # For AAPOR: aapor_2023 (2023-05) e_confex_event_id: str = Query(..., min_length=5, max_length=22), # For AAPOR: aapor_2023 (2024-05); aapor_2023 (2023-05)
event_id: str = Query(..., min_length=11, max_length=22), # For AAPOR: 9jW-Db-SF-wt (1478 2023-05); x2H2P2MYlXU (1447 2022-05) event_id: str = Query(..., min_length=11, max_length=22), # For AAPOR: MCz-Qm-48-j1 (1513 2024-05) 9jW-Db-SF-wt (1478 2023-05); x2H2P2MYlXU (1447 2022-05)
# Account ID For AAPOR: j5EBhRDqPuw # Account ID For AAPOR: j5EBhRDqPuw (20)
begin_loop: int = 1, begin_loop: int = 1,
end_loop: int = 250, end_loop: int = 250,
@@ -507,6 +508,8 @@ async def import_event_session_list(
# return False # return False
# Presentation File List for Presenter # Presentation File List for Presenter
# NOTE: Only the files under ChildList_VendorFiles where used for AAPOR 2023.
# NOTE: There are more files under ChildList_Files. This was ignored for AAPOR 2023.
log.info('Get presentation files for a presenter...') log.info('Get presentation files for a presenter...')
log.debug(confex_presentation_detail.get('ChildList_VendorFiles')) log.debug(confex_presentation_detail.get('ChildList_VendorFiles'))
event_presentation_data['confex_file_list'] = [] event_presentation_data['confex_file_list'] = []