Skip to content

Microsoft SQL Server Sink

Class: MicrosoftSQLServerSinkBlockV1

Source: inference.enterprise.workflows.enterprise_blocks.sinks.microsoft_sql_server.v1.MicrosoftSQLServerSinkBlockV1

The Microsoft SQL Server Sink block enables users to send data from a Roboflow workflow directly to a Microsoft SQL Server database. This block allows seamless integration of inference results, metadata, and processed data into structured SQL databases for further analysis, reporting, or automation.

Database Connection Setup

The block supports two authentication methods:

  1. Windows Authentication (Default): Uses the current Windows credentials
  2. SQL Server Authentication: Uses username and password

Required connection parameters: * Host: The IP address or hostname of the Microsoft SQL Server instance * Port: The port number for SQL Server (default: 1433) * Database: The target database where data will be inserted * Table Name: The name of the table where the data will be inserted

Optional authentication parameters (for SQL Server Authentication): * Username: The SQL Server username for authentication * Password: The password associated with the username

If username and password are not provided, the block will use Windows Authentication (trusted connection).

Data Input Format

The block expects data in a dictionary format or list of dictionaries that map to the target table columns:

# Single row
{
    "timestamp": "2025-02-12T10:30:00Z",
    "part_detected": "Defective Part",
    "confidence": 0.92,
    "camera_id": "CAM_001"
}

# Multiple rows
[
    {
        "timestamp": "2025-02-12T10:30:00Z",
        "part_detected": "Defective Part",
        "confidence": 0.92,
        "camera_id": "CAM_001"
    },
    {
        "timestamp": "2025-02-12T10:31:00Z",
        "part_detected": "Good Part",
        "confidence": 0.95,
        "camera_id": "CAM_002"
    }
]

Important Notes

  • The specified table must already exist in the database
  • The authenticated user must have INSERT permissions
  • Column names in the data must match the table schema
  • When using Windows Authentication, ensure the service account has proper permissions
  • The pyodbc package must be installed

Type identifier

Use the following identifier in step "type" field: roboflow_core/microsoft_sql_server_sink@v1to add the block as as step in your workflow.

Properties

Name Type Description Refs
name str Enter a unique identifier for this step..
host str SQL Server host address.
port int SQL Server port.
database str Target database name.
username str SQL Server username.
password str SQL Server password.
table_name str Target table name.
data Union[Dict[Any, Any], List[Dict[Any, Any]]] Data to insert into the database. Can be a single dictionary or list of dictionaries..
fire_and_forget bool Run in asynchronous mode for faster processing.

The Refs column marks possibility to parametrise the property with dynamic values available in workflow runtime. See Bindings for more info.

Available Connections

Compatible Blocks

Check what blocks you can connect to Microsoft SQL Server Sink in version v1.

Input and Output Bindings

The available connections depend on its binding kinds. Check what binding kinds Microsoft SQL Server Sink in version v1 has.

Bindings
  • input

    • host (string): SQL Server host address.
    • port (string): SQL Server port.
    • database (string): Target database name.
    • username (string): SQL Server username.
    • password (secret): SQL Server password.
    • table_name (string): Target table name.
    • data (dictionary): Data to insert into the database. Can be a single dictionary or list of dictionaries..
    • fire_and_forget (boolean): Run in asynchronous mode for faster processing.
  • output

    • error_status (boolean): Boolean flag.
    • message (string): String value.
Example JSON definition of step Microsoft SQL Server Sink in version v1
{
    "name": "<your_step_name_here>",
    "type": "roboflow_core/microsoft_sql_server_sink@v1",
    "host": "localhost",
    "port": 1433,
    "database": "production_db",
    "username": "db_user",
    "password": "$inputs.sql_password",
    "table_name": "detections",
    "data": {
        "object_detected": "Defective Part",
        "timestamp": "2025-02-12T10:30:00Z"
    },
    "fire_and_forget": true
}