mirror of
https://github.com/lancedb/lancedb.git
synced 2026-01-12 14:52:57 +00:00
Error implementations (#232)
Solves #216 by adding a check on table open for existence of the `.lance` file. Does not check for it for remote connections.
This commit is contained in:
@@ -252,7 +252,7 @@ class LanceDBConnection:
|
||||
if data is not None:
|
||||
tbl = LanceTable.create(self, name, data, schema, mode=mode)
|
||||
else:
|
||||
tbl = LanceTable(self, name)
|
||||
tbl = LanceTable.open(self, name)
|
||||
return tbl
|
||||
|
||||
def open_table(self, name: str) -> LanceTable:
|
||||
@@ -267,7 +267,7 @@ class LanceDBConnection:
|
||||
-------
|
||||
A LanceTable object representing the table.
|
||||
"""
|
||||
return LanceTable(self, name)
|
||||
return LanceTable.open(self, name)
|
||||
|
||||
def drop_table(self, name: str):
|
||||
"""Drop a table from the database.
|
||||
|
||||
@@ -308,6 +308,19 @@ class LanceTable:
|
||||
lance.write_dataset(data, tbl._dataset_uri, mode=mode)
|
||||
return tbl
|
||||
|
||||
@classmethod
|
||||
def open(cls, db, name):
|
||||
tbl = cls(db, name)
|
||||
if tbl._conn.is_managed_remote:
|
||||
# Not completely sure how to check for remote table existence yet.
|
||||
return tbl
|
||||
if not os.path.exists(tbl._dataset_uri):
|
||||
raise FileNotFoundError(
|
||||
f"Table {name} does not exist. Please first call db.create_table({name}, data)"
|
||||
)
|
||||
|
||||
return tbl
|
||||
|
||||
def delete(self, where: str):
|
||||
"""Delete rows from the table.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user