repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | title: '🐬 MySQL' |
| #3 | --- |
| #4 | |
| #5 | 1. Setup the MySQL loader by configuring the SQL db. |
| #6 | ```Python |
| #7 | from embedchain.loaders.mysql import MySQLLoader |
| #8 | |
| #9 | config = { |
| #10 | "host": "host", |
| #11 | "port": "port", |
| #12 | "database": "database", |
| #13 | "user": "username", |
| #14 | "password": "password", |
| #15 | } |
| #16 | |
| #17 | mysql_loader = MySQLLoader(config=config) |
| #18 | ``` |
| #19 | |
| #20 | For more details on how to setup with valid config, check MySQL [documentation](https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html). |
| #21 | |
| #22 | 2. Once you setup the loader, you can create an app and load data using the above MySQL loader |
| #23 | ```Python |
| #24 | from embedchain.pipeline import Pipeline as App |
| #25 | |
| #26 | app = App() |
| #27 | |
| #28 | app.add("SELECT * FROM table_name;", data_type='mysql', loader=mysql_loader) |
| #29 | # Adds `(1, 'What is your net worth, Elon Musk?', "As of October 2023, Elon Musk's net worth is $255.2 billion.")` |
| #30 | |
| #31 | response = app.query(question) |
| #32 | # Answer: As of October 2023, Elon Musk's net worth is $255.2 billion. |
| #33 | ``` |
| #34 | |
| #35 | 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. |
| #36 | |
| #37 | 3. 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: |
| #38 | ```Python |
| #39 | |
| #40 | from embedchain.chunkers.mysql import MySQLChunker |
| #41 | from embedchain.config.add_config import ChunkerConfig |
| #42 | |
| #43 | mysql_chunker_config = ChunkerConfig(chunk_size=1000, chunk_overlap=0, length_function=len) |
| #44 | mysql_chunker = MySQLChunker(config=mysql_chunker_config) |
| #45 | |
| #46 | app.add("SELECT * FROM table_name;", data_type='mysql', loader=mysql_loader, chunker=mysql_chunker) |
| #47 | ``` |
| #48 |