| 1 | [**@lancedb/lancedb**](../README.md) • **Docs** |
| 2 | |
| 3 | *** |
| 4 | |
| 5 | [@lancedb/lancedb](../globals.md) / Connection |
| 6 | |
| 7 | # Class: `abstract` Connection |
| 8 | |
| 9 | A LanceDB Connection that allows you to open tables and create new ones. |
| 10 | |
| 11 | Connection could be local against filesystem or remote against a server. |
| 12 | |
| 13 | A Connection is intended to be a long lived object and may hold open |
| 14 | resources such as HTTP connection pools. This is generally fine and |
| 15 | a single connection should be shared if it is going to be used many |
| 16 | times. However, if you are finished with a connection, you may call |
| 17 | close to eagerly free these resources. Any call to a Connection |
| 18 | method after it has been closed will result in an error. |
| 19 | |
| 20 | Closing a connection is optional. Connections will automatically |
| 21 | be closed when they are garbage collected. |
| 22 | |
| 23 | Any created tables are independent and will continue to work even if |
| 24 | the 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 | |
| 42 | Close the connection, releasing any underlying resources. |
| 43 | |
| 44 | It is safe to call this method multiple times. |
| 45 | |
| 46 | Any 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 | |
| 58 | Creates a new empty Table |
| 59 | |
| 60 | #### Parameters |
| 61 | |
| 62 | • **name**: `string` |
| 63 | |
| 64 | The name of the table. |
| 65 | |
| 66 | • **schema**: `SchemaLike` |
| 67 | |
| 68 | The 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 | |
| 84 | Creates a new Table and initialize it with new data. |
| 85 | |
| 86 | ##### Parameters |
| 87 | |
| 88 | • **options**: `object` & `Partial`<[`CreateTableOptions`](../interfaces/CreateTableOptions.md)> |
| 89 | |
| 90 | The 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 | |
| 100 | Creates a new Table and initialize it with new data. |
| 101 | |
| 102 | ##### Parameters |
| 103 | |
| 104 | • **name**: `string` |
| 105 | |
| 106 | The name of the table. |
| 107 | |
| 108 | • **data**: `TableLike` \| `Record`<`string`, `unknown`>[] |
| 109 | |
| 110 | Non-empty Array of Records |
| 111 | to 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 | |
| 125 | Return 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 | |
| 137 | Drop an existing table. |
| 138 | |
| 139 | #### Parameters |
| 140 | |
| 141 | • **name**: `string` |
| 142 | |
| 143 | The name of the table to drop. |
| 144 | |
| 145 | #### Returns |
| 146 | |
| 147 | `Promise`<`void`> |
| 148 | |
| 149 | *** |
| 150 | |
| 151 | ### isOpen() |
| 152 | |
| 153 | > `abstract` **isOpen**(): `boolean` |
| 154 | |
| 155 | Return 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 | |
| 167 | Open a table in the database. |
| 168 | |
| 169 | #### Parameters |
| 170 | |
| 171 | • **name**: `string` |
| 172 | |
| 173 | The 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 | |
| 187 | List all the table names in this database. |
| 188 | |
| 189 | Tables will be returned in lexicographical order. |
| 190 | |
| 191 | #### Parameters |
| 192 | |
| 193 | • **options?**: `Partial`<[`TableNamesOptions`](../interfaces/TableNamesOptions.md)> |
| 194 | |
| 195 | options to control the |
| 196 | paging / start point |
| 197 | |
| 198 | #### Returns |
| 199 | |
| 200 | `Promise`<`string`[]> |