Elffuss BraidHub

kikocis/lancedb public

4a63e77b7e97 · 3.7 KiBRenderedRawPermalink
1[**@lancedb/lancedb**](../README.md) • **Docs**
2
3***
4
5[@lancedb/lancedb](../globals.md) / Connection
6
7# Class: `abstract` Connection
8
9A LanceDB Connection that allows you to open tables and create new ones.
10
11Connection could be local against filesystem or remote against a server.
12
13A Connection is intended to be a long lived object and may hold open
14resources such as HTTP connection pools. This is generally fine and
15a single connection should be shared if it is going to be used many
16times. However, if you are finished with a connection, you may call
17close to eagerly free these resources. Any call to a Connection
18method after it has been closed will result in an error.
19
20Closing a connection is optional. Connections will automatically
21be closed when they are garbage collected.
22
23Any created tables are independent and will continue to work even if
24the underlying connection has been closed.
25
26## Constructors
27
28### new Connection()
29
30> **new Connection**(): [`Connection`](Connection.md)
31
32#### Returns
33
34[`Connection`](Connection.md)
35
36## Methods
37
38### close()
39
40> `abstract` **close**(): `void`
41
42Close the connection, releasing any underlying resources.
43
44It is safe to call this method multiple times.
45
46Any attempt to use the connection after it is closed will result in an error.
47
48#### Returns
49
50`void`
51
52***
53
54### createEmptyTable()
55
56> `abstract` **createEmptyTable**(`name`, `schema`, `options`?): `Promise`<[`Table`](Table.md)>
57
58Creates a new empty Table
59
60#### Parameters
61
62• **name**: `string`
63
64The name of the table.
65
66• **schema**: `SchemaLike`
67
68The schema of the table
69
70• **options?**: `Partial`<[`CreateTableOptions`](../interfaces/CreateTableOptions.md)>
71
72#### Returns
73
74`Promise`<[`Table`](Table.md)>
75
76***
77
78### createTable()
79
80#### createTable(options)
81
82> `abstract` **createTable**(`options`): `Promise`<[`Table`](Table.md)>
83
84Creates a new Table and initialize it with new data.
85
86##### Parameters
87
88• **options**: `object` & `Partial`<[`CreateTableOptions`](../interfaces/CreateTableOptions.md)>
89
90The options object.
91
92##### Returns
93
94`Promise`<[`Table`](Table.md)>
95
96#### createTable(name, data, options)
97
98> `abstract` **createTable**(`name`, `data`, `options`?): `Promise`<[`Table`](Table.md)>
99
100Creates a new Table and initialize it with new data.
101
102##### Parameters
103
104• **name**: `string`
105
106The name of the table.
107
108• **data**: `TableLike` \| `Record`<`string`, `unknown`>[]
109
110Non-empty Array of Records
111to be inserted into the table
112
113• **options?**: `Partial`<[`CreateTableOptions`](../interfaces/CreateTableOptions.md)>
114
115##### Returns
116
117`Promise`<[`Table`](Table.md)>
118
119***
120
121### display()
122
123> `abstract` **display**(): `string`
124
125Return a brief description of the connection
126
127#### Returns
128
129`string`
130
131***
132
133### dropTable()
134
135> `abstract` **dropTable**(`name`): `Promise`<`void`>
136
137Drop an existing table.
138
139#### Parameters
140
141• **name**: `string`
142
143The name of the table to drop.
144
145#### Returns
146
147`Promise`<`void`>
148
149***
150
151### isOpen()
152
153> `abstract` **isOpen**(): `boolean`
154
155Return true if the connection has not been closed
156
157#### Returns
158
159`boolean`
160
161***
162
163### openTable()
164
165> `abstract` **openTable**(`name`, `options`?): `Promise`<[`Table`](Table.md)>
166
167Open a table in the database.
168
169#### Parameters
170
171• **name**: `string`
172
173The name of the table
174
175• **options?**: `Partial`<`OpenTableOptions`>
176
177#### Returns
178
179`Promise`<[`Table`](Table.md)>
180
181***
182
183### tableNames()
184
185> `abstract` **tableNames**(`options`?): `Promise`<`string`[]>
186
187List all the table names in this database.
188
189Tables will be returned in lexicographical order.
190
191#### Parameters
192
193• **options?**: `Partial`<[`TableNamesOptions`](../interfaces/TableNamesOptions.md)>
194
195options to control the
196paging / start point
197
198#### Returns
199
200`Promise`<`string`[]>