2021-08-15 14:11:37 +00:00
|
|
|
---
|
2022-08-28 14:53:34 +00:00
|
|
|
slug: /en/sql-reference/table-functions/sqlite
|
2023-06-23 13:16:22 +00:00
|
|
|
sidebar_position: 185
|
2022-04-09 13:29:05 +00:00
|
|
|
sidebar_label: sqlite
|
2022-08-29 16:19:50 +00:00
|
|
|
title: sqlite
|
2021-08-15 14:11:37 +00:00
|
|
|
---
|
|
|
|
|
2021-08-19 04:29:38 +00:00
|
|
|
Allows to perform queries on a data stored in an [SQLite](../../engines/database-engines/sqlite.md) database.
|
2021-08-15 13:53:49 +00:00
|
|
|
|
2023-06-23 13:16:22 +00:00
|
|
|
**Syntax**
|
2021-08-15 13:53:49 +00:00
|
|
|
|
|
|
|
``` sql
|
2021-08-15 16:34:10 +00:00
|
|
|
sqlite('db_path', 'table_name')
|
2021-08-15 13:53:49 +00:00
|
|
|
```
|
|
|
|
|
2023-06-23 13:16:22 +00:00
|
|
|
**Arguments**
|
2021-08-15 13:53:49 +00:00
|
|
|
|
2023-04-19 15:55:29 +00:00
|
|
|
- `db_path` — Path to a file with an SQLite database. [String](../../sql-reference/data-types/string.md).
|
|
|
|
- `table_name` — Name of a table in the SQLite database. [String](../../sql-reference/data-types/string.md).
|
2021-08-15 13:53:49 +00:00
|
|
|
|
2021-08-15 16:34:10 +00:00
|
|
|
**Returned value**
|
2021-08-15 13:53:49 +00:00
|
|
|
|
2023-04-19 15:55:29 +00:00
|
|
|
- A table object with the same columns as in the original `SQLite` table.
|
2021-08-15 13:53:49 +00:00
|
|
|
|
|
|
|
**Example**
|
|
|
|
|
|
|
|
Query:
|
|
|
|
|
|
|
|
``` sql
|
2021-08-18 13:32:34 +00:00
|
|
|
SELECT * FROM sqlite('sqlite.db', 'table1') ORDER BY col2;
|
2021-08-15 13:53:49 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Result:
|
|
|
|
|
|
|
|
``` text
|
2021-08-18 13:32:34 +00:00
|
|
|
┌─col1──┬─col2─┐
|
2021-08-18 13:40:09 +00:00
|
|
|
│ line1 │ 1 │
|
|
|
|
│ line2 │ 2 │
|
|
|
|
│ line3 │ 3 │
|
2021-08-18 13:32:34 +00:00
|
|
|
└───────┴──────┘
|
2021-08-15 13:53:49 +00:00
|
|
|
```
|
|
|
|
|
2023-06-23 13:16:22 +00:00
|
|
|
**See Also**
|
2021-08-15 13:53:49 +00:00
|
|
|
|
2023-04-19 15:55:29 +00:00
|
|
|
- [SQLite](../../engines/table-engines/integrations/sqlite.md) table engine
|