-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inspired by https://ludwig.ai/latest/getting_started/. Topics will be covered in this PR: - Installation Guide - Integrate Data Source - USE SQL API - CREATE DATABASE SQL API
- Loading branch information
Showing
12 changed files
with
220 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _contributing: | ||
|
||
Contributing | ||
---------------- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Integrate Data Source | ||
===================== | ||
|
||
EvaDB supports an extensive data sources for both structured and unstructured data. | ||
|
||
1. Connect to an existing structured data source. | ||
|
||
.. code-block:: python | ||
cursor.query(""" | ||
CREATE DATABASE postgres_data WITH ENGINE = 'postgres', PARAMETERS = { | ||
"user": "eva", | ||
"password": "password", | ||
"host": "localhost", | ||
"port": "5432", | ||
"database": "evadb" | ||
};""").df() | ||
.. note:: | ||
|
||
Check :ref:`Create DATABASE statement<sql-create-database>` for syntax documentation and :ref:`Data Sources<data-sources>` for all supported data source engines. | ||
|
||
The above query connects to an exsiting Postgres database, which allows us to build AI applications in EvaDB without data migration. | ||
For example, the following query previews the available data using :ref:`SELECT<sql-select>`. | ||
|
||
.. code-block:: python | ||
cursor.query("SELECT * FROM postgres_data.food_review;").df() | ||
We can also run native queries in the connected database by the :ref:`USE<sql-use>` statement. | ||
|
||
.. code-block:: python | ||
cursor.query(""" | ||
USE postgres_data { | ||
INSERT INTO food_review (name, review) VALUES ('Customer 1', 'I ordered fried rice but it is too salty.') | ||
};""").df() | ||
2. Load unstructured data. EvaDB supports a wide range of type of unstructured data. Below are some examples: | ||
|
||
.. code-block:: python | ||
cursor.query( | ||
"LOAD IMAGE 'reddit-images/*.jpg' INTO reddit_dataset;" | ||
).df() | ||
We load the local reddit image dataset into EvaDB. | ||
|
||
.. code-block:: python | ||
cursor.query("LOAD VIDEO 's3://bucket/eva_videos/mnist.mp4' INTO MNISTVid;").df() | ||
We load the MNIST video from s3 bucket into EvaDB. | ||
|
||
.. note:: | ||
|
||
Check :ref:`LOAD statement<sql-load>` for all types of supported unstructured data. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. _data-sources: | ||
|
||
Data Sources | ||
============= | ||
|
||
Below are all supported data sources for EvaDB. We welcome adding new data source integrations in EvaDB. Check :ref:`add-data-source` for guidance. | ||
|
||
|
||
.. tableofcontents:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
PostgreSQL | ||
========== | ||
|
||
The connection to PostgreSQL is based on the `psycopg2 <https://pypi.org/project/psycopg2/>`_ library. | ||
|
||
Dependency | ||
---------- | ||
|
||
* psycopg2 | ||
|
||
|
||
Parameters | ||
---------- | ||
|
||
Required: | ||
|
||
* `user` is the database user. | ||
* `password` is the database password. | ||
* `host` is the host name, IP address, or URL. | ||
* `port` is the port used to make TCP/IP connection. | ||
* `database` is the database name. | ||
|
||
|
||
Create Connection | ||
----------------- | ||
|
||
.. code-block:: text | ||
CREATE DATABASE postgres_data WITH ENGINE = 'postgres', PARAMETERS = { | ||
"user": "eva", | ||
"password": "password", | ||
"host": "localhost", | ||
"port": "5432", | ||
"database": "evadb" | ||
}; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _sql-load: | ||
|
||
LOAD | ||
==== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. _sql-select: | ||
|
||
SELECT | ||
====== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.. _sql-use: | ||
|
||
USE | ||
=== | ||
|
||
The USE statement allows us to run arbitary native queries in the connected database. | ||
|
||
.. code:: text | ||
USE [database_connection] { [native_query] }; | ||
* [database_connection] is an external database connection instanced by the `CREATE DATABASE statement`. | ||
* [native_query] is an arbitary SQL query supprted by the [database_connection]. | ||
|
||
.. warning:: | ||
|
||
Currently EvaDB only supports single query in one USE statement. The [native_query] should not end with semicolon. | ||
|
||
Examples | ||
-------- | ||
|
||
.. code:: text | ||
USE postgres_data { | ||
DROP TABLE IF EXISTS food_review | ||
}; | ||
USE postgres_data { | ||
CREATE TABLE food_review (name VARCHAR(10), review VARCHAR(1000)) | ||
}; | ||
USE postgres_data { | ||
INSERT INTO food_review (name, review) VALUES ('Customer 1', 'I ordered fried rice but it is too salty.') | ||
}; | ||