Skip to content

Instantly share code, notes, and snippets.

View atrox39's full-sized avatar
⌨️
Coding...

Eddy Ortega atrox39

⌨️
Coding...
View GitHub Profile
Write-Host "Hi!"

Guía Técnica: Monitoreo de Inserciones sin Modificación de DB

Método: SQL Server Extended Events con Ring Buffer (In-Memory)

Este documento detalla el procedimiento para capturar eventos de INSERT en una base de datos de "solo lectura" o con restricciones de licenciamiento, sin crear triggers ni alterar el esquema.


1. Concepto de la Solución

Utilizamos el motor de Extended Events (XEvents) de SQL Server apuntando a un Ring Buffer.

  • No intrusivo: No se crean objetos (tablas, triggers, vistas) en la base de datos objetivo.
using System;
using System.Runtime.InteropServices;
using System.IO;
class Program
{
[DllImport("dotenv.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void CallDotenvLoad(string filename_c_str = null);
public static void Main()
{
from dotenv import load_dotenv
from langchain_perplexity import ChatPerplexity
from langchain_core.utils.utils import convert_to_secret_str
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain.tools import tool
import os
load_dotenv()
@tool
line-length = 80
indent-width = 2
target-version = "py311"
[format]
indent-style = "space"
docstring-code-format = true
quote-style = "single"
line-ending = "lf"
from dotenv import load_dotenv
from ollama import Client
from pydantic import BaseModel
import os
load_dotenv()
class Article(BaseModel):
title: str
content: str
@atrox39
atrox39 / HttpRequestSQLServer.sql
Created August 12, 2025 22:42
HttpRequest with SQLServer
DECLARE @Product VARCHAR(MAX) = '';
DECLARE @CMD NVARCHAR(4000) =
'powershell -Command "&" {'
+ ' Invoke-RestMethod -Uri ''https://fakestoreapi.com/products'' -Method Get'
+ ' -ContentType ''application/json'' '
+ ' } ';
DECLARE @CMD_VARCHAR VARCHAR(8000);
SET @CMD_VARCHAR = CAST(@CMD AS varchar(8000))
DECLARE @Response TABLE (OutputText NVARCHAR(MAX));
INSERT INTO @Response EXEC xp_cmdshell @CMD_VARCHAR;
@atrox39
atrox39 / HttpClientPs.ps1
Created March 27, 2025 18:40
Cliente Http simple para peticiones HTTP (GET, POST, PUT, DELETE, PATCH)
# Simple HTTPClient
param(
[string]$method,
[string]$url,
[string]$body = "{}",
[switch]$help
)
Add-Type -AssemblyName System.Net.Http
$validMethods = @("GET", "POST", "PUT", "DELETE", "PATCH")