# tdslite > Lightweight, header-only Microsoft SQL Server (MSSQL) client in pure C++11 for Arduino, ESP32, ESP8266, ESP-IDF and desktop, working with just 2 kB of RAM. tdslite connects microcontrollers (Arduino, ESP32, ESP8266) and desktop programs directly to Microsoft SQL Server and Azure SQL over the TDS protocol. It is header-only C++11 with no dependencies, streams result rows through a callback so it runs in 2 kB of RAM, supports parameterized queries and TLS (TDS 8.0 strict mode), and plugs into any network stack through small backends (Arduino EthernetClient/WiFiClient, BSD sockets, ESP-IDF esp-tls, Boost.ASIO). The C++ API reference is generated by Doxygen and linked from the Reference section. ## Overview - [Home](https://tdslite.github.io/tdslite/latest/index.md): tdslite is a lightweight, header-only Microsoft SQL Server (MSSQL) client in C++11. Connect Arduino, ESP32, ESP8266, ESP-IDF and desktop programs directly to SQL Server, in as little as 2 kB of RAM. ## Tutorials - [Tutorials](https://tdslite.github.io/tdslite/latest/tutorials/index.md): Step-by-step tutorials: run your first SQL Server query from an Arduino, an ESP32 with PlatformIO, ESP-IDF, or a Linux or macOS computer with tdslite. - [Arduino IDE](https://tdslite.github.io/tdslite/latest/tutorials/arduino/index.md): Connect an Arduino Uno with an Ethernet shield to Microsoft SQL Server: install tdslite in the Arduino IDE, log in, create a table and read rows. - [PlatformIO (ESP32)](https://tdslite.github.io/tdslite/latest/tutorials/platformio/index.md): Connect an ESP32 to Microsoft SQL Server over Wi-Fi with PlatformIO and tdslite: create a project, log in, run queries and read SQL Server's error messages. - [ESP-IDF](https://tdslite.github.io/tdslite/latest/tutorials/esp-idf/index.md): Query Microsoft SQL Server from an ESP-IDF application on ESP32, ESP32-C3 or ESP32-S3: add tdslite from the ESP Component Registry, configure it in menuconfig, read rows. - [Desktop (Linux, macOS)](https://tdslite.github.io/tdslite/latest/tutorials/desktop/index.md): Query Microsoft SQL Server from a C++ program on Linux or macOS with tdslite, a header-only library: build with one compiler command and read rows. ## How-to guides - [How-to guides](https://tdslite.github.io/tdslite/latest/how-to/index.md): Task-focused guides for tdslite: installing, ESP8266, Azure SQL, parameterized queries, stored procedures, logging sensor data, error handling, TLS, memory tuning and custom network backends. - [Install the library](https://tdslite.github.io/tdslite/latest/how-to/install/index.md): Install tdslite, the C++ SQL Server client, with the Arduino IDE Library Manager, PlatformIO, the ESP-IDF Component Manager or CMake. - [Connect an ESP8266](https://tdslite.github.io/tdslite/latest/how-to/esp8266/index.md): Query Microsoft SQL Server from an ESP8266 (NodeMCU, Wemos D1 mini) with tdslite: Wi-Fi setup, buffer sizes for the ESP8266's RAM, and TLS with BearSSL. - [Connect to Azure SQL Database](https://tdslite.github.io/tdslite/latest/how-to/azure-sql/index.md): Connect to Azure SQL Database from an ESP32, ESP8266, ESP-IDF or desktop C++ with tdslite: firewall rules, SQL authentication, TLS certificates, and Azure-specific errors. - [Run parameterized queries](https://tdslite.github.io/tdslite/latest/how-to/parameterized-queries/index.md): Run parameterized SQL Server queries from Arduino, ESP32 or C++ with tdslite's execute_rpc: bind integers, strings and binary values safely as @p0, @p1. - [Read column values](https://tdslite.github.io/tdslite/latest/how-to/read-columns/index.md): Read SQL Server column values with tdslite: integers, floats, varchar and nvarchar strings, NULLs, binary data, money and column names in a row callback. - [Call a stored procedure](https://tdslite.github.io/tdslite/latest/how-to/stored-procedures/index.md): Execute SQL Server stored procedures with tdslite: pass parameters, read their result sets, get OUTPUT parameters and return values, and detect errors raised inside them. - [Log sensor readings](https://tdslite.github.io/tdslite/latest/how-to/log-sensor-data/index.md): Insert sensor readings (temperature, humidity, ...) from an ESP32, ESP8266 or Arduino into a Microsoft SQL Server table with tdslite, and reconnect when the connection drops. - [Send ESPHome sensor data](https://tdslite.github.io/tdslite/latest/how-to/esphome/index.md): Store ESPHome sensor readings in Microsoft SQL Server straight from an ESP32, act on query results, and show database values as sensors, with the tdslite sql_server external component: YAML only, no MQTT broker, Node-RED or gateway in between. - [Arduino and ESP32 projects with SQL Server](https://tdslite.github.io/tdslite/latest/how-to/projects/index.md): Complete ESP32 and ESP8266 projects that store their data in Microsoft SQL Server with tdslite: an MQTT bridge, a battery weather station, RFID attendance, and an energy monitor. - [MQTT to SQL Server bridge](https://tdslite.github.io/tdslite/latest/how-to/projects/mqtt-sql-bridge/index.md): Store MQTT messages from Tasmota, ESPHome or your own devices in Microsoft SQL Server with an ESP32 or ESP8266 running tdslite and PubSubClient: no Node-RED, Telegraf or PC in between. - [Battery weather station](https://tdslite.github.io/tdslite/latest/how-to/projects/weather-station/index.md): Build a battery-powered ESP32 or ESP8266 weather station that reads a BME280, stores each reading in Microsoft SQL Server with tdslite, and deep-sleeps in between. - [RFID attendance](https://tdslite.github.io/tdslite/latest/how-to/projects/rfid-attendance/index.md): Build an RFID attendance and access system: an ESP32 or ESP8266 with an RC522 reader checks cards against Microsoft SQL Server with tdslite and logs every scan, without a web server or PHP. - [Energy monitor](https://tdslite.github.io/tdslite/latest/how-to/projects/energy-monitor/index.md): Log household power use with an ESP32 or ESP8266 and a PZEM-004T v3 meter into Microsoft SQL Server with tdslite, and get daily and monthly kWh, cost and standby load from SQL queries. - [Handle errors and server messages](https://tdslite.github.io/tdslite/latest/how-to/handle-errors/index.md): Handle errors with tdslite: check connect, execute_query and execute_rpc results, receive SQL Server's error messages, and reconnect after a lost connection. - [Connect with TLS](https://tdslite.github.io/tdslite/latest/how-to/tls/index.md): Encrypt SQL Server connections with TLS (TDS 8.0 strict mode) using tdslite on ESP32 and ESP8266 (WiFiClientSecure), ESP-IDF (esp-tls) and desktop (OpenSSL). - [Fit tdslite into a small RAM budget](https://tdslite.github.io/tdslite/latest/how-to/memory/index.md): Fit a SQL Server client into 2 kB of RAM: size tdslite's network buffer, keep strings in flash with TDSL_PMEMSTR, and measure memory on an Arduino Uno. - [Use your own memory allocator](https://tdslite.github.io/tdslite/latest/how-to/custom-allocator/index.md): Replace malloc and free in tdslite with your own allocator functions, or remove the default allocator entirely with TDSL_DISABLE_DEFAULT_ALLOCATOR. - [Write a network backend](https://tdslite.github.io/tdslite/latest/how-to/custom-backend/index.md): Run tdslite on any network stack: use an EthernetClient-compatible client, or implement a network backend with five functions on network_io_base. - [Troubleshoot](https://tdslite.github.io/tdslite/latest/how-to/troubleshooting/index.md): Fix common tdslite problems: connection_failed, login_failed (error 18456), TLS errors, numbers reading as zero, garbled nvarchar strings, request_too_large. ## Reference - [Reference](https://tdslite.github.io/tdslite/latest/reference/index.md): Reference for tdslite: connection parameters, SQL data type mappings, error codes, network backends, limits, examples, tested hardware and the C++ API. - [Connection parameters](https://tdslite.github.io/tdslite/latest/reference/connection-parameters/index.md): Every tdslite connection parameter with its type and default: server_name, port, user_name, password, db_name, packet_size, retry settings. - [Data types](https://tdslite.github.io/tdslite/latest/reference/data-types/index.md): How tdslite reads SQL Server column types (int, varchar, nvarchar, money, binary, datetime2...) and which C++ types bind as query parameters. - [Results and error codes](https://tdslite.github.io/tdslite/latest/reference/errors/index.md): All tdslite result and error codes: connect, execute_query, execute_rpc, the info callback's message fields, and each network backend's error codes. - [Network backends](https://tdslite.github.io/tdslite/latest/reference/network-backends/index.md): tdslite's network backends for Arduino, BSD sockets, ESP-IDF TLS and Boost.ASIO: headers, driver types, functions and TLS options. - [Limits](https://tdslite.github.io/tdslite/latest/reference/limits/index.md): tdslite limits: query length, row size, packet size, supported SQL Server versions, C++ standard, measured RAM and flash use on an Arduino Uno, and the ESPHome component's limits and throughput on an ESP32. - [Examples](https://tdslite.github.io/tdslite/latest/reference/examples/index.md): Example programs for tdslite: Arduino sketches, ESP32 and ESP8266 Wi-Fi and TLS sketches, ESP-IDF projects, and a desktop SQL shell. - [Tested hardware](https://tdslite.github.io/tdslite/latest/reference/tested-hardware/index.md): Boards tdslite is tested on (Arduino Uno, Mega, Nano, Uno WiFi Rev. 2, Portenta H7, ESP32, ESP8266) and the boards CI builds for. - [C++ API](https://tdslite.github.io/tdslite/latest/reference/api/index.md): The tdslite C++ API reference, generated with Doxygen: the driver, rows and fields, query parameters, server messages and network backends. ## Explanation - [Explanation](https://tdslite.github.io/tdslite/latest/explanation/index.md): Background on tdslite's design: its goals, the network abstraction, the memory model, how TDS versions and encryption work, and direct connections versus gateways. - [Design goals](https://tdslite.github.io/tdslite/latest/explanation/design/index.md): Why tdslite is built the way it is: zero-cost C++11 for microcontrollers, no dependencies, header-only, and only the parts of TDS that devices need. - [The network abstraction](https://tdslite.github.io/tdslite/latest/explanation/network-abstraction/index.md): Why tdslite doesn't open sockets itself: how the driver and its network backends fit together through a compile-time (CRTP) interface. - [Memory model](https://tdslite.github.io/tdslite/latest/explanation/memory-model/index.md): How tdslite uses memory: one fixed network buffer, rows streamed through a callback, brief heap allocations, and strings kept in flash. - [TDS versions and encryption](https://tdslite.github.io/tdslite/latest/explanation/tds-and-tls/index.md): TDS 7.1 logins, SQL Server's type conversions, and TDS 8.0 strict encryption explained, including why transactions must stay within one query over TLS. - [Direct connections and gateways](https://tdslite.github.io/tdslite/latest/explanation/direct-vs-gateway/index.md): The trade-offs of connecting microcontrollers straight to Microsoft SQL Server with tdslite, versus going through a REST API or MQTT gateway: security, credentials, networks, scale and maintenance.