{"library":"soda-core-sqlserver","title":"Soda Core SQL Server","type":"library","description":"Soda Core SQL Server is a plugin for Soda Core, a data quality monitoring framework. It enables connecting to and scanning data quality checks against SQL Server databases. This library provides the necessary data source integration, allowing users to define checks on their SQL Server data using Soda's YAML-based configuration. Version 3.5.6 is current, and releases typically align with the active development cadence of the main `soda-core` library.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install soda-core-sqlserver"],"cli":{"name":"soda","version":"soda-core, version 3.5.6"}},"imports":["This package enables `type: sqlserver` in your `configuration.yml`.\n\nFor programmatic scan execution: `from soda.scan import Scan`"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/soda-core-sqlserver/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import os\nfrom soda.scan import Scan\n\n# Ensure environment variables are set for the quickstart to run\n# For local testing, replace os.environ.get with actual values or create a .env file\nhost = os.environ.get('SQLSERVER_HOST', 'localhost')\nport = os.environ.get('SQLSERVER_PORT', '1433')\ndatabase = os.environ.get('SQLSERVER_DATABASE', 'your_database')\nusername = os.environ.get('SQLSERVER_USERNAME', 'sa')\npassword = os.environ.get('SQLSERVER_PASSWORD', 'your_password')\n\n# Create a dummy configuration.yml and checks.yml for demonstration\n# In a real scenario, these files would be persisted.\nconfig_yaml_content = f\"\"\"\ndata_source:\n  type: sqlserver\n  host: \"{host}\"\n  port: \"{port}\"\n  database: \"{database}\"\n  username: \"{username}\"\n  password: \"{password}\"\n  # Add other connection options if needed, e.g., for trusted connections or specific drivers\n  # Example using system-installed ODBC Driver 17 for SQL Server on Linux/macOS:\n  # connection_string_user_defined_options: \"Driver={{ODBC Driver 17 for SQL Server}};Encrypt=no;TrustServerCertificate=yes;\"\n  # Example for Windows Trusted Connection (if your SQL Server supports it):\n  # connection_string_user_defined_options: \"Trusted_Connection=Yes;Encrypt=no;\"\n\"\"\"\n\nchecks_yaml_content = \"\"\"\nchecks for demo_table:\n  - row_count > 0\n  - missing_count(id) = 0\n\"\"\"\n\nconfig_path = 'configuration.yml'\nchecks_path = 'checks.yml'\n\nwith open(config_path, 'w') as f:\n    f.write(config_yaml_content)\nwith open(checks_path, 'w') as f:\n    f.write(checks_yaml_content)\n\nprint(\"Configuration and checks files created. Running Soda Scan...\")\n\nscan = Scan()\nscan.set_data_source_name('data_source') # Corresponds to the top-level key in configuration.yml\nscan.add_configuration_path(config_path)\nscan.add_checks_path(checks_path)\nscan.execute()\n\nif scan.has_failures():\n    print(\"Scan completed with failures.\")\nelse:\n    print(\"Scan completed successfully without failures.\")\n\n# Clean up generated files (optional, remove in persistent setups)\nos.remove(config_path)\nos.remove(checks_path)\n","lang":"python","description":"This quickstart demonstrates how to configure Soda Core to connect to a SQL Server database and run a simple data quality scan programmatically. It generates `configuration.yml` and `checks.yml` files, then executes a scan. Ensure your environment variables `SQLSERVER_HOST`, `SQLSERVER_DATABASE`, `SQLSERVER_USERNAME`, `SQLSERVER_PASSWORD` are set, and an ODBC driver for SQL Server is installed on your system. Replace placeholder values or environment variables with your actual SQL Server connection details.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}