Clickhouse async
            ClickhouseAsync
¶
    
              Bases: BaseModel
An async clickhouse client.
Usage
from tradingtoolbox.clickhouse import ClickhouseAsync
async_client = await ClickhouseAsync.create(
    host="localhost",
    port=8123,
    user="default",
    password="",
    database="default",
)
# Or you can create it without passing anything, and it will use the above defaults
async_client = await ClickhouseAsync.create()
            create_table
¶
create_table(table_name: str, schema: str, partition_key: str = '', order_by: str = '', primary_key: str = '', drop: bool = False)
Create a table
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
table_name | 
            
                  str
             | 
            
               The name of the table  | 
            required | 
schema | 
            
                  str
             | 
            
               The schema of the table  | 
            required | 
partition_key | 
            
                  str
             | 
            
               The partition key  | 
            
                  ''
             | 
          
order_by | 
            
                  str
             | 
            
               The order by  | 
            
                  ''
             | 
          
primary_key | 
            
                  str
             | 
            
               The primary key  | 
            
                  ''
             | 
          
drop | 
            
                  bool
             | 
            
               Whether to drop the table if it already exists  | 
            
                  False
             | 
          
Source code in src/tradingtoolbox/clickhouse/clickhouse_async.py
              
            drop_table
¶
    Drops a table from the database
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
table_name | 
            
                  str
             | 
            
               The table's name  | 
            required | 
            execute_command
¶
    Allows you to run any command you want
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
query | 
            
                  str
             | 
            
               The query to execute  | 
            required | 
            insert_df
¶
    Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
df | 
            
                  DataFrame
             | 
            
               The dataframe to insert  | 
            required | 
table_name | 
            
                  str
             | 
            
               The name of the table to insert into  | 
            required | 
drop | 
            
                  bool
             | 
            
               Whether to drop the table if it already exists  | 
            
                  True
             | 
          
Source code in src/tradingtoolbox/clickhouse/clickhouse_async.py
              
            optimize_table
¶
    Optimizes a table
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
table_name | 
            
                  str
             | 
            
               The name of the table  | 
            required | 
Source code in src/tradingtoolbox/clickhouse/clickhouse_async.py
              
            
            query
¶
    Runs a query
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
query | 
            
                  str
             | 
            
               The query to run  | 
            required | 
            query_df
¶
    Runs a query and returns the results as a dataframe
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
query | 
            
                  str
             | 
            
               The query to run  | 
            required |