analyse db issue
This commit is contained in:
parent
3643ccdae0
commit
e026ba3806
3 changed files with 18 additions and 4 deletions
|
|
@ -34,7 +34,7 @@ APP_TOKEN_EXPIRY=300
|
||||||
APP_ALLOWED_ORIGINS=http://localhost:8080,https://playground.poweron-center.net,https://playground-int.poweron-center.net,http://localhost:5176,https://nyla.poweron-center.net, https://nyla-int.poweron-center.net
|
APP_ALLOWED_ORIGINS=http://localhost:8080,https://playground.poweron-center.net,https://playground-int.poweron-center.net,http://localhost:5176,https://nyla.poweron-center.net, https://nyla-int.poweron-center.net
|
||||||
|
|
||||||
# Logging configuration
|
# Logging configuration
|
||||||
APP_LOGGING_LOG_LEVEL = INFO
|
APP_LOGGING_LOG_LEVEL = DEBUG
|
||||||
APP_LOGGING_LOG_FILE = /home/site/wwwroot/poweron.log
|
APP_LOGGING_LOG_FILE = /home/site/wwwroot/poweron.log
|
||||||
APP_LOGGING_FORMAT = %(asctime)s - %(levelname)s - %(name)s - %(message)s
|
APP_LOGGING_FORMAT = %(asctime)s - %(levelname)s - %(name)s - %(message)s
|
||||||
APP_LOGGING_DATE_FORMAT = %Y-%m-%d %H:%M:%S
|
APP_LOGGING_DATE_FORMAT = %Y-%m-%d %H:%M:%S
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ APP_TOKEN_EXPIRY=300
|
||||||
APP_ALLOWED_ORIGINS=http://localhost:8080,https://playground.poweron-center.net,https://playground-int.poweron-center.net,http://localhost:5176,https://nyla.poweron-center.net,https://nyla-int.poweron-center.net
|
APP_ALLOWED_ORIGINS=http://localhost:8080,https://playground.poweron-center.net,https://playground-int.poweron-center.net,http://localhost:5176,https://nyla.poweron-center.net,https://nyla-int.poweron-center.net
|
||||||
|
|
||||||
# Logging configuration
|
# Logging configuration
|
||||||
APP_LOGGING_LOG_LEVEL = INFO
|
APP_LOGGING_LOG_LEVEL = DEBUG
|
||||||
APP_LOGGING_LOG_FILE = /home/site/wwwroot/poweron.log
|
APP_LOGGING_LOG_FILE = /home/site/wwwroot/poweron.log
|
||||||
APP_LOGGING_FORMAT = %(asctime)s - %(levelname)s - %(name)s - %(message)s
|
APP_LOGGING_FORMAT = %(asctime)s - %(levelname)s - %(name)s - %(message)s
|
||||||
APP_LOGGING_DATE_FORMAT = %Y-%m-%d %H:%M:%S
|
APP_LOGGING_DATE_FORMAT = %Y-%m-%d %H:%M:%S
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,14 @@ class DatabaseConnector:
|
||||||
Uses PostgreSQL with JSONB columns for flexible data storage.
|
Uses PostgreSQL with JSONB columns for flexible data storage.
|
||||||
"""
|
"""
|
||||||
def __init__(self, dbHost: str, dbDatabase: str, dbUser: str = None, dbPassword: str = None, dbPort: int = None, userId: str = None):
|
def __init__(self, dbHost: str, dbDatabase: str, dbUser: str = None, dbPassword: str = None, dbPort: int = None, userId: str = None):
|
||||||
|
# DEBUG: Log constructor parameters
|
||||||
|
logger.info(f"DEBUG: DatabaseConnector constructor called with:")
|
||||||
|
logger.info(f" dbHost: '{dbHost}' (type: {type(dbHost)})")
|
||||||
|
logger.info(f" dbDatabase: '{dbDatabase}' (type: {type(dbDatabase)})")
|
||||||
|
logger.info(f" dbUser: '{dbUser}' (type: {type(dbUser)})")
|
||||||
|
logger.info(f" dbPort: {dbPort} (type: {type(dbPort)})")
|
||||||
|
logger.info(f" userId: '{userId}' (type: {type(userId)})")
|
||||||
|
|
||||||
# Store the input parameters
|
# Store the input parameters
|
||||||
self.dbHost = dbHost
|
self.dbHost = dbHost
|
||||||
self.dbDatabase = dbDatabase
|
self.dbDatabase = dbDatabase
|
||||||
|
|
@ -101,6 +109,10 @@ class DatabaseConnector:
|
||||||
def _create_database_if_not_exists(self):
|
def _create_database_if_not_exists(self):
|
||||||
"""Create the database if it doesn't exist."""
|
"""Create the database if it doesn't exist."""
|
||||||
try:
|
try:
|
||||||
|
# DEBUG: Log all database configuration values
|
||||||
|
logger.info(f"DEBUG: Database configuration - Host: {self.dbHost}, Database: {self.dbDatabase}, User: {self.dbUser}, Port: {self.dbPort}")
|
||||||
|
logger.info(f"DEBUG: Database name type: {type(self.dbDatabase)}, value: '{self.dbDatabase}'")
|
||||||
|
|
||||||
# Use the configured user for database creation
|
# Use the configured user for database creation
|
||||||
conn = psycopg2.connect(
|
conn = psycopg2.connect(
|
||||||
host=self.dbHost,
|
host=self.dbHost,
|
||||||
|
|
@ -118,8 +130,10 @@ class DatabaseConnector:
|
||||||
exists = cursor.fetchone()
|
exists = cursor.fetchone()
|
||||||
|
|
||||||
if not exists:
|
if not exists:
|
||||||
# Create database
|
# Create database with proper quoting for names with hyphens
|
||||||
cursor.execute(f"CREATE DATABASE {self.dbDatabase}")
|
quoted_db_name = f'"{self.dbDatabase}"'
|
||||||
|
logger.info(f"DEBUG: Creating database with quoted name: {quoted_db_name}")
|
||||||
|
cursor.execute(f"CREATE DATABASE {quoted_db_name}")
|
||||||
logger.info(f"Created database: {self.dbDatabase}")
|
logger.info(f"Created database: {self.dbDatabase}")
|
||||||
else:
|
else:
|
||||||
logger.info(f"Database {self.dbDatabase} already exists")
|
logger.info(f"Database {self.dbDatabase} already exists")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue