DEV Community

Jesse Phillips
Jesse Phillips

Posted on

3

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.

Heroku

Deliver your unique apps, your own way.

Heroku tackles the toil — patching and upgrading, 24/7 ops and security, build systems, failovers, and more. Stay focused on building great data-driven applications.

Learn More

Top comments (0)

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay