githubEdit

Programmatic

Dolt ships with a built in MySQL compatible server. To start the server for your Dolt database, you run dolt sql-server in the repository directory. The dolt sql-server command starts a MySQL compatible server for the Dolt database on port 3306 with no authentication. The database name is the name of the repository directory but with dashes (-) replaced with underscores (_). So dolt-test repository name would become dolt_test database name. See this documentation for more configuration details.

Once a server is running, any MySQL client should be able to connect to Dolt SQL Server in the exact same way it connects to a standard MySQL database. For instance, if you are running a Dolt sql-server locally, you can connect to it with the MySQL client mysql like so:

$ mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9-Vitess

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

We explicitly support the programmatic clients outlined in this document through integration testing. Tests are run on GitHub pull requests to Dolt in a Ubuntu environment in a Docker container. If you would like another MySQL compatible client supported and tested, please let us knowarrow-up-right.

The test code linked to below is a good way to get started connecting to a Dolt SQL server if you are not familiar how to connect to MySQL in your language of choice. The code establishes a connection, runs some simple queries, verifies the output comes back as expected, and closes the connection.

⚠️ Disclaimer: This is a recommendation based on our testing with Dolt. While the MySQL and MariaDB connector libraries are largely similar, we recommend using the MySQL connectors. They are more thoroughly tested with Dolt, whereas the MariaDB connectors have some known quirks, such as silently stripping certain SQL join hint comments.

Python

We currently support multiple Python MySQL connectors, including mysql.connectorarrow-up-right, pymysqlarrow-up-right, and mariadbarrow-up-right. These are all fully written in Python, however, the MariaDB connector does build from the C connector.

mysql.connector

pymysql

mariadb

SQLAlchemy

We also support the SQLAlchemyarrow-up-right library. SQLAlchemy requires a connector that is specified in the connection string. Choose one of the supported connectors listed above, and then pass that to the SQLAlchemy connection string, as in the snippet taken from the connector test below:

Node

We support the standard mysql Node library as well as the mariadb connector.

mysql

mariadb

Java

We support multiple Java MySQL connectors, including mysql-connector-j, mariadb-java-client, and r2dbc-mariadb.

mysql-connector-j

mariadb-java-client

r2dbc-mariadb

C

We support libmysqlclientarrow-up-right distributed by MySQL, the MariaDB Connector/Carrow-up-right, and the MariaDB ODBC connectorarrow-up-right. For the tests, we apt-get install -y libmysqlclient-dev and compile against the dynamic binaries.

libmysqlclient

MariaDB Connector/C

MariaDB ODBC

C++

We support mysql-connector-cpp and mariadb-connector-cpp. We build these connectors through the available packages in MariaDB download pagearrow-up-right or Debian's apt-get.

mysql-connector-cpp

mariadb-connector-cpp

Dotnet

We support MySQL.Data.MySqlClientarrow-up-right distributed by MySQL and the asynchronous MySqlConnectorarrow-up-right. We tested the client using .NET 9.0 SDKarrow-up-right.

MySQL.Data.MySqlClient

MySQLConnector

Perl

We support the DBD::mysqlarrow-up-right and DBD::MariaDBarrow-up-right packages that implement DBIarrow-up-right for MySQL. These connectors rely on libmysqlclientarrow-up-right or MariaDB Connector/Carrow-up-right.

DBD::mysql

DBD::MariaDB

PHP

We support the built-in mysqliarrow-up-right extension and PDOarrow-up-right API for connecting to MySQL.

Go

We support multiple Go MySQL clients, including go-sql-driver/mysqlarrow-up-right (the standard MySQL driver for the database/sqlarrow-up-right package) and go-mysqlarrow-up-right.

go-sql-driver/mysql

go-mysql

Ruby

We support the native ruby/mysqlarrow-up-right library and the native mysql2arrow-up-right library. The mysql/rubyarrow-up-right package uses the MySQL C API and has not been ported to MySQL client version 8arrow-up-right. Thus, we do not support mysql/ruby.

mysql2

ruby/mysql

R

We support the legacy RMySQLarrow-up-right and newer RMariaDBarrow-up-right R clients. Both implement DBIarrow-up-right and require either libmysqlclientarrow-up-right or MariaDBConnector/Carrow-up-right.

There is also an open-source, third-party wrapper for working with Dolt, called DoltRarrow-up-right. This tool is well-maintained by EcoHealth Alliancearrow-up-right and provides an easy way to work with local or remote Dolt databases from within R Studio.

Rust

We support the mysql cratearrow-up-right in Rust.

Elixir

We support multiple Elixir MySQL clients, including MyXQLarrow-up-right (a native Elixir MySQL driver) and mysql-otparrow-up-right (an Erlang MySQL driver usable from Elixir).

MyXQL

mysql-otp

Swift

We support the Perfect-MariaDBarrow-up-right connector for Swift, which provides MariaDB/MySQL connectivity using the MariaDB Connector/C library.

Last updated

Was this helpful?