Elffuss BraidHub

kikocis/lancedb public

main · 1.7 KiBRenderedRawPermalink
1# Migration from Sync to Async API
2
3A new asynchronous API has been added to LanceDb. This API is built
4on top of the rust lancedb crate (instead of being built on top of
5pylance). This will help keep the various language bindings in sync.
6There are some slight changes between the synchronous and the asynchronous
7APIs. This document will help you migrate. These changes relate mostly
8to the Connection and Table classes.
9
10## Almost all functions are async
11
12The most important change is that almost all functions are now async.
13This means the functions now return `asyncio` coroutines. You will
14need to use `await` to call these functions.
15
16## Connection
17
18* The connection now has a `close` method. You can call this when
19 you are done with the connection to eagerly free resources. Currently
20 this is limited to freeing/closing the HTTP connection for remote
21 connections. In the future we may add caching or other resources to
22 native connections so this is probably a good practice even if you aren't using remote connections.
23
24 In addition, the connection can be used as a context manager which may
25 be a more convenient way to ensure the connection is closed.
26
27 It is not mandatory to call the `close` method. If you don't call it
28 the connection will be closed when the object is garbage collected.
29
30## Table
31
32* The table now has a `close` method, similar to the connection. This
33 can be used to eagerly free the cache used by a Table object. Similar
34 to the connection, it can be used as a context manager and it is not
35 mandatory to call the `close` method.
36* Previously `Table.schema` was a property. Now it is an async method.
37* The method `Table.__len__` was removed and `len(table)` will no longer
38 work. Use `Table.count_rows` instead.