Skip to content

tdslite

Connect Arduino, ESP32 and C++ to Microsoft SQL Server

A lightweight, header-only SQL Server client in pure C++11.
Query a database from an Arduino Uno with 2 kB of RAM, or from anything bigger.

Get started Install View on GitHub

  • Header-only
  • Zero dependencies
  • No C++ standard library needed
  • MIT licensed
  • Tested on SQL Server 2017 – 2025
  • Fits on the smallest boards


    One fixed network buffer that you size, rows streamed to a callback one at a time. A 500-row result set reads through a 256-byte buffer.

  • Runs on any network stack


    Arduino EthernetClient and WiFiClient, BSD sockets, ESP-IDF, Boost.ASIO, or a backend you write yourself in five functions.

  • TLS when you need it


    TDS 8.0 strict encryption on ESP32 and ESP8266, ESP-IDF and desktop, with certificate checks on by default.

  • Small, plain API


    Connect, execute_query, execute_rpc with bound parameters. No exceptions, no RTTI: every call returns a result you can check.

A taste

// Called once for each row of a result set
static void print_row(void *, const tdsl::tds_colmetadata_token &, const tdsl::tdsl_row & row) {
    const auto id   = row [0].as<tdsl::int32_t>();
    const auto name = row [1].as<tdsl::char_view>();
    Serial.printf("%d: %.*s\n", static_cast<int>(id), static_cast<int>(name.size()), name.data());
}

void setup() {
    // ... connect to Wi-Fi, then:
    decltype(driver)::connection_parameters params;
    params.server_name = "192.168.1.10";
    params.user_name   = "sa";
    params.password    = "<password>";

    if (driver.connect(params) == decltype(driver)::e_driver_error_code::success) {
        driver.execute_query("SELECT id, name FROM fruits", print_row);
    }
}

Where to go next

  • Tutorials

    New to tdslite? Run your first query on Arduino, PlatformIO, ESP-IDF or a desktop computer, step by step.

  • How-to guides

    Recipes for a specific job: parameterized queries, TLS, error handling, squeezing into a small RAM budget.

  • Reference

    Connection parameters, type mappings, error codes, limits and the C++ API.

  • Explanation

    Why tdslite is built the way it is: the design goals, the network abstraction, the memory model and TDS encryption.

Frequently asked questions

Can an Arduino connect to SQL Server directly?
Yes. tdslite speaks SQL Server's own protocol (TDS), so an Arduino with an Ethernet shield or Wi-Fi logs in and runs queries without a web service or gateway in between. It runs on an Arduino Uno, with 2 kB of RAM. See the Arduino tutorial.
Does it work with ESP32 and ESP8266?
Yes, with the Arduino core (WiFiClient, or WiFiClientSecure for TLS), PlatformIO, or ESP-IDF. See the PlatformIO and ESP-IDF tutorials, and Connect an ESP8266.
Which SQL Server versions are supported?
CI tests SQL Server 2017, 2019, 2022 and 2025 on every pull request. Encrypted connections need SQL Server 2025, SQL Server 2022 on Windows, or Azure SQL. See Limits, and Connect to Azure SQL Database (not tested in CI).
Is the connection encrypted?
It can be: tdslite supports TLS in TDS 8.0 strict mode on ESP32, ESP8266, ESP-IDF and desktop. The plaintext backends send everything unencrypted. See Connect with TLS.
Does it support parameterized queries?
Yes, with execute_rpc, which sends the values separately from the SQL text. See Run parameterized queries.
Does it support Windows authentication?
No, only SQL Server authentication (user name and password).
What does it need from the compiler and platform?
A C++11 compiler, nothing more: no C++ standard library, no exceptions, no RTTI, no external dependencies. It's header-only, so there's nothing to build or link.