-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
64 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,92 @@ | ||
Connect to Database | ||
============================ | ||
|
||
EvaDB supports an extensive data sources for both structured and unstructured data. | ||
EvaDB supports an extensive range of data sources for structured and unstructured data. | ||
|
||
1. Connect to an existing structured data source. | ||
.. note:: | ||
|
||
Learn more about structured and unstructured data in :doc:`Data Sources <getting-started/data-sources>`. | ||
|
||
|
||
Connect to a SQL Database System | ||
-------------------------------- | ||
|
||
1. Use the `CREATE DATABASE` statement to connect to an existing SQL database. | ||
|
||
.. code-block:: python | ||
cursor.query(""" | ||
CREATE DATABASE postgres_data WITH ENGINE = 'postgres', PARAMETERS = { | ||
"user": "eva", | ||
"password": "password", | ||
"host": "localhost", | ||
"port": "5432", | ||
"database": "evadb" | ||
};""").df() | ||
CREATE DATABASE restaurant_reviews | ||
WITH ENGINE = 'postgres', | ||
PARAMETERS = { | ||
"user": "eva", | ||
"password": "password", | ||
"host": "localhost", | ||
"port": "5432", | ||
"database": "restaurant_reviews" | ||
};""").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>`. | ||
Go over the :ref:`CREATE DATABASE<sql-create-database>` statement for more details. The :ref:`Databases<databases>` page lists all the database systems that EvaDB currently supports. | ||
|
||
.. code-block:: python | ||
cursor.query("SELECT * FROM postgres_data.food_review;").df() | ||
2. Preview the Available Data Using `SELECT` | ||
|
||
We can also run native queries in the connected database by the :ref:`USE<sql-use>` statement. | ||
You can now preview the available data in the `restaurant_reviews` database with a standard :ref:`SELECT<sql-select>` 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() | ||
SELECT * | ||
FROM restaurant_reviews.food_review; | ||
""").df() | ||
3. Run Native Queries in the Connected Database With `USE` | ||
|
||
2. Load unstructured data. EvaDB supports a wide range of type of unstructured data. Below are some examples: | ||
You can also run native queries directly in the connected database system by the :ref:`USE<sql-use>` statement. | ||
|
||
.. code-block:: python | ||
cursor.query( | ||
"LOAD IMAGE 'reddit-images/*.jpg' INTO reddit_dataset;" | ||
).df() | ||
""" | ||
USE restaurant_reviews { | ||
INSERT INTO food_review (name, review) | ||
VALUES ( | ||
'Customer 1', | ||
'I ordered fried rice but it is too salty.' | ||
) | ||
}; | ||
""").df() | ||
We load the local reddit image dataset into EvaDB. | ||
Load Unstructured Data | ||
----------------------- | ||
|
||
EvaDB supports diverse types of unstructured data. Here are some examples: | ||
|
||
1. Load Images from Local Filesystem | ||
|
||
You can load a collection of images obtained from Reddit from the local filesystem into EvaDB using the :ref:`LOAD<sql-load>` statement. | ||
|
||
.. code-block:: python | ||
cursor.query(""" | ||
LOAD IMAGE 'reddit-images/*.jpg' | ||
INTO reddit_dataset; | ||
""").df() | ||
cursor.query("LOAD VIDEO 's3://bucket/eva_videos/mnist.mp4' INTO MNISTVid;").df() | ||
2. Load Video from Cloud Bucket | ||
|
||
We load the MNIST video from s3 bucket into EvaDB. | ||
You can load a video from an S3 cloud bucket into EvaDB using the :ref:`LOAD<sql-load>` statement. | ||
|
||
.. code-block:: python | ||
cursor.query(""" | ||
LOAD VIDEO 's3://bucket/eva_videos/mnist.mp4' | ||
INTO MNISTVid; | ||
""").df() | ||
.. note:: | ||
|
||
Check :ref:`LOAD statement<sql-load>` for all types of supported unstructured data. | ||
Go over the :ref:`LOAD statement<sql-load>` statement for more details on the types of unstructured data that EvaDB supports. | ||
|
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