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 know.

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.

Python

We currently support two native Python MySQL connectors, mysql.connector and pymysql. These are all native (ie. do not depend on a MySQL compiled C library) Python libraries available through pip.

mysql.connector

pymysql

SQLAlchemy

We also support the SQLAlchemy 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:

conn_string_base = "mysql+mysqlconnector://"

engine = create_engine(conn_string_base +
                       "{user}@127.0.0.1:{port}/{db}".format(user=user,
                                                             port=port,
                                                             db=db)

Node

We support the standard mysql Node library.

Java

We support the Java client distributed on the MySQL website called mysql-connector-java. For our test we use the architecture independent build.

C

We support libmysqlclient distributed by MySQL. On OSX, we tested the client distributed by brew install mysql-client. For the Ubuntu tests, we apt install -y libmysqlclient-dev. We then use pkg-config to generate the proper CFLAGS and LDFLAGS.

C++

We support mysql-connector-cpp. Getting it to work correctly required we checkout and build mysql-connector-cpp using the proper flags and dependencies. This was a relatively heavy lift but you can use our build logic as an example.

Dotnet

We support MySQL.Data.MySqlClient distributed by MySQL and the asynchronous MySqlConnector. On OSX and Ubuntu we tested the client using .Net core SDK.

MySQL.Data.MySqlClient

MySQLConnector

Perl

We support the DBD::mysql package that implements DBI for MySQL. This connector relies on libmysqlclient.

PHP

We support the built in mysqli extension and PDO API for connecting to MySQL.

Go

We support the go-sql-driver/mysql package. This is the MySQL driver for the database/sql package.

Ruby

We support the native ruby/mysql library and the native mysql2 library. The mysql/ruby package uses the MySQL C API and has not been ported to MySQL client version 8. Thus, we do not support mysql/ruby.

mysql2

ruby/mysql

R

We support the legacy RMySQL and newer RMariaDB R clients. Both implement DBI and require either libmysqlclient or MariaDBConnector/C.

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

Rust

We support the mysql crate in Rust.

Last updated