Reading

Cloning a Database

1
$ dolt clone dolthub/ip-to-country && cd ip-to-country
2
cloning https://doltremoteapi.dolthub.com/dolthub/ip-to-country
3
23,716 of 23,716 chunks complete. 0 chunks being downloaded currently.
Copied!
Other databases to clone are available on DoltHub.

SQL shell

1
$ dolt sql
2
# Welcome to the DoltSQL shell.
3
# Statements must be terminated with ';'.
4
# "exit" or "quit" (or Ctrl-D) to exit.
5
ip_to_country> show tables;
6
+---------------+
7
| Table |
8
+---------------+
9
| IPv4ToCountry |
10
| IPv6ToCountry |
11
+---------------+
12
ip_to_country> describe IPv4tocountry;
13
+--------------------+----------+------+-----+---------+-------+
14
| Field | Type | Null | Key | Default | Extra |
15
+--------------------+----------+------+-----+---------+-------+
16
| IPFrom | BIGINT | NO | PRI | | |
17
| IpTo | BIGINT | NO | PRI | | |
18
| Registry | LONGTEXT | YES | | | |
19
| AssignedDate | BIGINT | YES | | | |
20
| CountryCode2Letter | LONGTEXT | YES | | | |
21
| CountryCode3Letter | LONGTEXT | YES | | | |
22
| Country | LONGTEXT | YES | | | |
23
+--------------------+----------+------+-----+---------+-------+
Copied!
Run single SQL statements with the -q argument.
1
$ dolt sql -q 'select Country,count(*) from IPv4ToCountry group by Country order by count(*) desc' -r csv > results.csv
2
$ head results.csv
3
Country,COUNT(*)
4
United States,56561
5
Brazil,10977
6
Russian Federation,10871
7
Germany,9332
8
China,8528
9
Canada,8163
10
United Kingdom,8116
11
Australia,7979
12
India,6165
Copied!

SQL Server

Run your dolt database as a SQL server with dolt sql-server. Talk to it with any tool that speaks MySQL, such as the MySQL client.
For homebrew on OS X, use this command:
1
$ brew install mysql-client
2
Updating Homebrew...
3
==> Auto-updated Homebrew!
4
.
5
.
6
.
7
==> Downloading https://homebrew.bintray.com/bottles/mysql-client-8.0.19.mojave.bottle.tar.gz
8
==> Downloading from https://akamai.bintray.com/c8/c8d2434da809237c64cd3dd4139a2bd148b6773fca040c001cc7af468354e761?__gda__=exp=1590007034~hmac=ae2a06b14b4eef499282b0f2e473bde458d83b3f8d61218565e3b468af5b5171&response-content-disposition=attachment%3Bfilena
9
######################################################################## 100.0%
10
.
11
.
12
.
Copied!
See the MySQL documentation for details on installation on other platforms.
Start the server:
1
$ dolt sql-server --log-level info
2
Starting server with Config HP="localhost:3306"|U="root"|P=""|T="30000"|R="false"|L="info"
Copied!
1
$ mysql -h 127.0.0.1 -u root
2
Welcome to the MySQL monitor. Commands end with ; or \g.
3
Your MySQL connection id is 21
4
Server version: 5.7.9-Vitess
5
6
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
7
8
Oracle is a registered trademark of Oracle Corporation and/or its
9
affiliates. Other names may be trademarks of their respective
10
owners.
11
12
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
13
14
mysql> show databases;
15
+--------------------+
16
| Database |
17
+--------------------+
18
| information_schema |
19
| ip_to_country |
20
+--------------------+
21
2 rows in set (0.00 sec)
22
23
mysql> use ip_to_country;
24
Reading table information for completion of table and column names
25
You can turn off this feature to get a quicker startup with -A
26
27
Database changed
28
mysql> show tables;
29
+---------------+
30
| Table |
31
+---------------+
32
| IPv4ToCountry |
33
| IPv6ToCountry |
34
+---------------+
35
2 rows in set (0.00 sec)
Copied!

Python

To read Dolt data in Pandas or another Python data tool, install doltpy. See instructions in the Python quickstart guide.

R

R can use the RMySQL package to connect to a Dolt database server.
Install the required package and load the DBI package:
1
install.packages("RMySQL")
2
library(RMySQL)
3
library(DBI)
Copied!
We can now instantiate a connection object and start checking out the data:
1
con <- dbConnect(MySQL(),
2
dbname = 'ip_to_country',
3
host = '127.0.0.1',
4
port = 3306,
5
user = 'root')
6
> dbListTables(con)
7
[1] "IPv4ToCountry" "IPv6ToCountry"
Copied!

Next steps

Check out the guide to Writing to Dolt to learn options for updating the database.
Or dive right into the docs for the SQL interface or the CLI.
Last modified 1mo ago