workflows.fit
Back to n8n workflows
n8n templateFreeBy Chandan Singh

Synchronize MySQL database schemas to Pinecone with OpenAI embeddings

This workflow synchronizes MySQL database table schemas with a vector database in a controlled, idempotent manner. Each database table is indexed as a single vector to preserve complete schema context for AI-based ret...

DevelopmentCore NodesData & StorageAILangchainSticky NoteManual TriggerSet
Loading interactive preview...

Template notes

This workflow synchronizes MySQL database table schemas with a vector database in a controlled, idempotent manner. Each database table is indexed as a single vector to preserve complete schema context for AI-based retrieval and reasoning. The workflow prevents duplicate vectors and automatically handles schema changes by detecting differences and re-indexing only when required.

How it works - The workflow starts with a manual trigger and loads global configuration values. - All database tables are discovered and processed one by one inside a loop. - For each table, a normalized schema representation is generated, and a deterministic hash is calculated. - A metadata table is checked to determine whether a vector already exists for the table. - If a vector exists, the stored schema hash is compared with the current hash to detect schema changes. - When a schema change is detected, the existing vector and metadata are deleted. - The updated table schema is embedded as a single vector (without chunking) and upserted into the vector database. - Vector identifiers and schema hashes are persisted for future executions.

Setup steps - Set the MySQL database name using mysqldatabasename. - Configure the Pinecone index name using pineconeindex. - Set the vector namespace using vectornamespace. - Configure the Pinecone index host using vectorindexhost. - Add your Pinecone API key using pineconeapikey. - Select the embedding model using embeddingmodel. - Configure text processing options: - chunksize - chunkoverlap - Set the metadata table identifier using dataTableId. - Save and run the workflow manually to perform the initial schema synchronization.

Limitations - This workflow indexes database table schemas only. Table data (rows) are not embedded or indexed. - Each table is stored as a single vector. Very large or highly complex schemas may approach model token limits depending on the selected embedding model. - Schema changes are detected using a hash-based comparison. Non-structural changes that do not affect the schema representation will not trigger re-indexing.