dolthub / doltpy

A Python API for Dolt
Apache License 2.0
56 stars 13 forks source link

`DoltSQLServerContext` connection fails when there are unstaged changes #181

Open alkamid opened 2 years ago

alkamid commented 2 years ago
$ dolt status
On branch test_data_types
Untracked files:
  (use "dolt add <table|doc>" to include in what will be committed)
        new table:      mytable
with DoltSQLServerContext(dolt, ServerConfig(user="root", password="")) as doltsql:
    df = doltsql.read_pandas("mytable")

ValueError                                Traceback (most recent call last)
Input In [8], in <cell line: 1>()
----> 1 with DoltSQLServerContext(dolt, ServerConfig(user="root", password="")) as doltsql:
      2     df = doltsql.read_pandas("mytable")

File ~/.cache/pypoetry/virtualenvs/science-s3M63NV5-py3.9/lib/python3.9/site-packages/doltpy/sql/sql.py:368, in DoltSQLServerContext.__enter__(self)
    365 def __enter__(self):
    366     if not self.dolt.status().is_clean:
    367         # TODO better error messages
--> 368         raise ValueError("DoltSQLServerManager does not support ")
    369     if self.server_config.branch:
    370         current_branch, _ = self.dolt.branch()

After committing changes:

$ dolt status
On branch test_data_types
nothing to commit, working tree clean

it's working fine.