-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support create tempporay table & ibis tutorial
- Loading branch information
d h
authored and
d h
committed
Nov 27, 2024
1 parent
fa5a520
commit 48be2ee
Showing
2 changed files
with
156 additions
and
68 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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# **Connecting to MyDuckServer using Ibis** | ||
|
||
[ibis](https://ibis-project.org/) offers an efficient way to handle data analysis tasks without loading the entire dataset into memory.This tutorial will guide you through setting up a connection using Ibis and performing basic operations with myduckserver. | ||
|
||
### Steps | ||
|
||
1. **Installing ibis** | ||
|
||
``` | ||
//use conda | ||
conda install -c conda-forge ibis-mysql | ||
//use pip | ||
pip install 'ibis-framework[mysql]' | ||
``` | ||
|
||
2. **Run MyDuck Server:** | ||
|
||
``` | ||
docker run -p 13306:3306 -p 15432:5432 apecloud/myduckserver:latest | ||
``` | ||
|
||
3. **Connecting to the Myduck Server** | ||
|
||
``` | ||
import ibis | ||
host = '127.0.0.1' | ||
port = 13306 | ||
user = 'root' | ||
password = '' | ||
database = 'mydb' #should first create the database mydb. | ||
con = ibis.mysql.connect( | ||
host=host, | ||
port=port, | ||
user=user, | ||
password=password, | ||
database=database | ||
) | ||
``` | ||
|
||
4. **Executing Queries** | ||
|
||
``` | ||
import ibis | ||
table_name = 'persistent_temp_table' | ||
schema = ibis.schema([('id', 'int32'), ('value', 'double')]) | ||
if table_name not in con.list_tables(): | ||
con.create_table(table_name, schema=schema) | ||
con.insert(table_name, [{'id': 1, 'value': 10.5}]) | ||
table = con.table(table_name) | ||
result = table.execute() | ||
print(result) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|