For more details on how to setup with valid config, check MySQL documentation.
Once you setup the loader, you can create an app and load data using the above MySQL loader
Copy
from embedchain.pipeline import Pipeline as Appapp = App()app.add("SELECT * FROM table_name;", data_type='mysql', loader=mysql_loader)# Adds `(1, 'What is your net worth, Elon Musk?', "As of October 2023, Elon Musk's net worth is $255.2 billion.")`response = app.query(question)# Answer: As of October 2023, Elon Musk's net worth is $255.2 billion.
NOTE: The add function of the app will accept any executable query to load data. DO NOT pass the CREATE, INSERT queries in add function.
We automatically create a chunker to chunk your SQL data, however if you wish to provide your own chunker class. Here is how you can do that:
Copy
from embedchain.chunkers.mysql import MySQLChunkerfrom embedchain.config.add_config import ChunkerConfigmysql_chunker_config = ChunkerConfig(chunk_size=1000, chunk_overlap=0, length_function=len)mysql_chunker = MySQLChunker(config=mysql_chunker_config)app.add("SELECT * FROM table_name;", data_type='mysql', loader=mysql_loader, chunker=mysql_chunker)