Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions application/single_app/semantic_kernel_plugins/sql_schema_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,40 +298,36 @@ def get_database_schema(
}
)

except Exception as e:
error_msg = f"Failed to get database schema: {str(e)}"
print(f"[SQLSchemaPlugin] ERROR: {error_msg}")
log_event(f"[SQLSchemaPlugin] get_database_schema failed", extra={
"error": str(e),
"database_type": self.database_type,
"database": self.database
})
return ResultWithMetadata(
{"error": error_msg},
{"source": "sql_schema_plugin", "success": False}
)

# Get tables
tables_query = self._get_tables_query(include_system_tables, table_filter)
cursor.execute(tables_query)
tables = cursor.fetchall()

# Get schema for each table
for table_row in tables:
table_name = table_row[0] if isinstance(table_row, (list, tuple)) else table_row
table_schema = self._get_table_schema_data(cursor, table_name)
schema_data["tables"][table_name] = table_schema

# Get relationships
relationships = self._get_relationships_data(cursor)
schema_data["relationships"] = relationships

log_event(f"[SQLSchemaPlugin] Retrieved schema for {len(schema_data['tables'])} tables")
return ResultWithMetadata(schema_data, self.metadata)

except Exception as e:
log_event(f"[SQLSchemaPlugin] Error getting database schema: {e}")
raise
error_msg = f"Failed to get database schema: {str(e)}"
print(f"[SQLSchemaPlugin] ERROR: {error_msg}")
log_event(f"[SQLSchemaPlugin] get_database_schema failed", extra={
"error": str(e),
"database_type": self.database_type,
"database": self.database
})
return ResultWithMetadata(
{"error": error_msg},
{"source": "sql_schema_plugin", "success": False}
)

@kernel_function(description="Get detailed schema for a specific table")
@plugin_function_logger("SQLSchemaPlugin")
Expand Down