Introducing Dolt Profiles

FEATURE RELEASECOMMAND LINE
4 min read

Dolt's CLI has been getting a bit of a revamp recently. With more CLI commands migrated to use SQL to retrieve results, it's easier than ever to access your remote data this way. Our most recently migrated command is dolt log!

$ dolt --host dolthub-profile-demo-1.dbs.hosted.doltdb.com --port 3306 --user steph --password ***** --use-db demoDB2 log
commit u4lskheib9d6rap3l2j14daj94scuoq6 (HEAD -> main)  
Author: steph <stephanie@dolthub.com>Date:  Thu Aug 31 11:08:21 -0700 2023  
  
        exciting stuff  

commit 1mkkp29a6vikuqvscjsilgu28aur2ko8  
Author: Dolt System Account <doltuser@dolthub.com>  
Date:  Thu Aug 31 11:07:43 -0700 2023  
  
        Initialize data repository        

You can see some of our new global arguments at work here. It's easy to see how typing this many global arguments for every command could get pretty unwieldy quickly. Thus, we have dolt profile to the rescue! You can now create a named configuration of global arguments and use it with any migrated command. The above log call could be simplified greatly:

$ dolt --profile demoProfile log
commit u4lskheib9d6rap3l2j14daj94scuoq6 (HEAD -> main)  
Author: steph <stephanie@dolthub.com>Date:  Thu Aug 31 11:08:21 -0700 2023  
  
        exciting stuff  

commit 1mkkp29a6vikuqvscjsilgu28aur2ko8  
Author: Dolt System Account <doltuser@dolthub.com>  
Date:  Thu Aug 31 11:07:43 -0700 2023  
  
        Initialize data repository

How dolt profile Works

dolt profile is laid out similarly to dolt remote. You can call dolt profile for a list of profile names currently set, or use the --verbose flag to also show all the details for each profile.

$ dolt profile -v
myProfile
	user: myUser
	password: myPassword
	host: myHosted.dbs.hosted.doltdb.com
	port: 3306
	no-tls: false
	data-dir:
	doltcfg-dir:
	privilege-file:
	branch-control-file:
	use-db: demoDB

To add a new profile, use dolt profile add with all the flags you want to set.

$ dolt profile add -u myUser -p myPassword myProfile

To remove an existing profile, use dolt profile remove with the profile name.

$ dolt profile remove myProfile

All profile information is stored in ~/.dolt/config.json.

Profiles In Action

Now that you know the basics of how dolt profile works, here are some examples of useful profiles you might create.

If you're using the command line to access a remote Dolt sql-server with client credentials, you might have a profile named my myHosted configured as follows:

myHosted
	user: myUser
	password: myPassword
	host: myHosted.dbs.hosted.doltdb.com

You might have multiple databases in your remote server which might each have a profile set up with the appropriate --use-db flag:

myHosted_dbA
	user: myUser
	password: myPassword
	host: myHosted.dbs.hosted.doltdb.com
	use-db: dbA

Even if you're using local directories as data sources, you might find it useful to set up a profile with all the options you need, like:

localProfile
	data-dir: /path/to/dir
	doltcfg-dir: /path/to/cfg-dir
	use-db: myDB

Advanced Profile Tips

To finish up this tour of dolt profile, I'll offer a couple more advanced tips.

  1. If you add a profile with the name default, this will become a special default profile. Its configurations will be automatically applied to any migrated CLI command. CLI commands that haven't been migrated yet will operate normally as if no global arguments were given. This can be really handy to save you from even needing to type --profile default, but can be risky if you forget there is a default profile set and get unexpected behavior with no --profile specified. To remove a default profile, just use dolt profile remove default.

  2. You can still use any global argument with the --profile flag to augment or overwrite the configuration in the profile. For example, let's say I set up a profile named demo to access a hosted instance:

    demo
        user: <user>
        password: <password>
        host: dolthub-profile-demo-1.dbs.hosted.doltdb.com
        port: 3306
        use-db: demoDB
        

    Running dolt log with this profile will let me see the commit history of database demoDB:

    $ dolt --profile demo log
    commit vfu46pm9rheldtbgj9a9p510331re9u4 (HEAD -> main)
    Author: steph <stephanie@dolthub.com>
    Date:  Thu Aug 31 14:39:55 -0700 2023
    
            Changes to table1 from main
    
    commit 8n53d7jcp4cmdi0mibc16cbs7db4ob4j
    Author: steph <stephanie@dolthub.com>
    Date:  Wed Aug 30 16:06:04 -0700 2023
    
            create table1
    
    commit rt4n5k769k0al1kkrkvjccgg7033t7kr
    Author: Dolt System Account <doltuser@dolthub.com>
    Date:  Wed Aug 30 12:11:41 -0700 2023
    
            Initialize data repository

    I also have another database in this instance that I can access by overwriting the --use-db flag like so:

    $ dolt --profile demo --use-db demoDB2 log
    commit 3bds0vmv1op1vmomrvr5qfjfj1nh6ltd (HEAD -> main)
    Author: steph <stephanie@dolthub.com>
    Date:  Wed Aug 30 16:38:39 -0700 2023
    
            inserted data into table2, table3
    
    commit iug8jld1be3bbn05kjeoso5enjl9j8hb
    Author: steph <stephanie@dolthub.com>
    Date:  Wed Aug 30 16:13:44 -0700 2023
    
            created table2 and table3
    
    commit j41fcr6rdj4japjtm6kauaorudbmhr6o
    Author: Dolt System Account <doltuser@dolthub.com>
    Date:  Wed Aug 30 16:13:01 -0700 2023
    
            Initialize data repository

    I can also add any additional global flags as needed, like specifying a branch:

    $ dolt --profile demo --branch branch1 log
    commit skk7c6d9uep5p7rj2b55qtdj9fcp8cki (HEAD -> branch1)
    Author: steph <stephanie@dolthub.com>
    Date:  Thu Aug 31 14:40:21 -0700 2023
    
            Changes to table1 from branch1
    
    commit 8n53d7jcp4cmdi0mibc16cbs7db4ob4j
    Author: steph <stephanie@dolthub.com>
    Date:  Wed Aug 30 16:06:04 -0700 2023
    
            create table1
    
    commit rt4n5k769k0al1kkrkvjccgg7033t7kr
    Author: Dolt System Account <doltuser@dolthub.com>
    Date:  Wed Aug 30 12:11:41 -0700 2023
    
            Initialize data repository

That's all for today, I hope you find profiles useful in your Dolt adventures. Come check us out on discord and let us know what features you're excited to see next. (Maybe update for dolt profile?) We would love to hear from you!

SHARE

JOIN THE DATA EVOLUTION

Get started with Dolt

Or join our mailing list to get product updates.