DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Jesse Phillips
Jesse Phillips

Posted on

Working with Dolt Version Control Database

I'm currently exploring the idea of building an application using Dolt and Dlang.

I'd been following along with the getting started docs:

And the key thing I missed was the relationship between the server and the Dolt database. Dolt provides a command-line tool where you can initialize a database in any folder, just like with git.

Utilizing the SQL interface requires that the Server be started with the database directory as the working directory. This can be as simple as:

$ mkdir newdb
$ cd newdb
$ dolt init
$ dolt sql-server
Enter fullscreen mode Exit fullscreen mode

Or as complicated as

$ sudo useradd -r -m -d /var/lib/doltdb dolt
$ cd /var/lib/doltdb
$ sudo -u dolt dolt config --global --add user.email doltServer@company.com
$ sudo -u dolt dolt config --global --add user.name "Dolt Server Account"
$ cd /var/lib/doltdb
$ sudo -u dolt mkdir -p databases/my_db
$ cd databases/my_db
$ sudo -u dolt dolt init
$ sudo -u dolt /usr/local/bin/dolt sql-server -u root
Enter fullscreen mode Exit fullscreen mode

I started with the second one here which is really about standing up the machine as a Database Server, The first option would have been perfect for my personal usage.

Once the server is up and running I could build a simple D application to connect:

$ dub init
$ sudo apt install default-libmysqlclient-dev
$ dub add arsd-official:mssql
$ gvim source/app.d
Enter fullscreen mode Exit fullscreen mode
import arsd.mysql;

void main() {
    auto db = new MySql("127.0.0.1", "root", null, "getting_started");
}
Enter fullscreen mode Exit fullscreen mode

The connection needed to use the loopback IP as it would not work specifying localhost. It will launch the server on 3306 which is default SQL, but it can be changed with -P

$ dolt sql-server -P 63444
Enter fullscreen mode Exit fullscreen mode
new MySql("127.0.0.1", "root", null, "getting_started", 63444);
Enter fullscreen mode Exit fullscreen mode

Enjoy.

Top comments (0)

We want your help! Become a Tag Moderator.
Fill out this survey and help us moderate our community by becoming a tag moderator here at DEV.