{"id":13721906,"url":"https://github.com/long2ice/meilisync","last_synced_at":"2025-05-16T06:05:34.363Z","repository":{"id":100854026,"uuid":"606779235","full_name":"long2ice/meilisync","owner":"long2ice","description":"Realtime sync data from MySQL/PostgreSQL/MongoDB to Meilisearch","archived":false,"fork":false,"pushed_at":"2025-04-14T15:59:57.000Z","size":567,"stargazers_count":332,"open_issues_count":54,"forks_count":47,"subscribers_count":6,"default_branch":"dev","last_synced_at":"2025-05-10T12:22:59.372Z","etag":null,"topics":["datasync","etl","meilisearch","mongodb","mysql","postgresql","realtime-synchronization"],"latest_commit_sha":null,"homepage":"https://github.com/long2ice/meilisync","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/long2ice.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-26T14:46:11.000Z","updated_at":"2025-05-08T13:03:27.000Z","dependencies_parsed_at":"2023-12-08T03:31:34.887Z","dependency_job_id":"73927888-9618-4126-9ae7-e774954f19cd","html_url":"https://github.com/long2ice/meilisync","commit_stats":null,"previous_names":["meilisync/meilisync"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/long2ice%2Fmeilisync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/long2ice%2Fmeilisync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/long2ice%2Fmeilisync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/long2ice%2Fmeilisync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/long2ice","download_url":"https://codeload.github.com/long2ice/meilisync/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478187,"owners_count":22077676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datasync","etl","meilisearch","mongodb","mysql","postgresql","realtime-synchronization"],"created_at":"2024-08-03T01:01:22.678Z","updated_at":"2025-05-16T06:05:29.354Z","avatar_url":"https://github.com/long2ice.png","language":"Python","funding_links":[],"categories":["Integrations"],"sub_categories":["Community Integrations"],"readme":"# meilisync\n\n[![image](https://img.shields.io/pypi/v/meilisync.svg?style=flat)](https://pypi.python.org/pypi/meilisync)\n[![image](https://img.shields.io/github/license/meilisync/meilisync)](https://github.com/meilisync/meilisync)\n[![image](https://github.com/meilisync/meilisync/workflows/pypi/badge.svg)](https://github.com/meilisync/meilisync/actions?query=workflow:pypi)\n[![image](https://github.com/meilisync/meilisync/workflows/ci/badge.svg)](https://github.com/meilisync/meilisync/actions?query=workflow:ci)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/meilisync?color=5cc141)](https://github.com/long2ice/meilisync)\n\n## Introduction\n\nRealtime sync data from MySQL/PostgreSQL/MongoDB to Meilisearch.\n\nThere is also a web admin dashboard for meilisync [meilisync-admin](https://github.com/long2ice/meilisync-admin).\n\n## Install\n\nInstall from pypi:\n\n- `pip install meilisync[mysql]` for MySQL.\n- `pip install meilisync[postgres]` for PostgreSQL.\n- `pip install meilisync[mongo]` for MongoDB.\n- `pip install meilisync[all]` for all.\n- `pip install meilisync[redis]` for redis progress.\n\n## Use docker (Recommended)\n\nYou can use docker to run `meilisync`:\n\n```yaml\nversion: \"3\"\nservices:\n  meilisync:\n    image: long2ice/meilisync\n    volumes:\n      - ./config.yml:/meilisync/config.yml\n    restart: always\n```\n\n## Prerequisites\n\n- `MySQL`: `binlog_format = ROW`, use binary log.\n- `PostgreSQL`: `wal_level = logical` and install `wal2json` extension, use logical replication.\n- `MongoDB`: enable replica set mode, use change stream.\n\n## Quick Start\n\nIf you run `meilisync` without any arguments, it will try to load the configuration from `config.yml` in the current\ndirectory.\n\n```shell\n❯ meilisync --help\n\n Usage: meilisync [OPTIONS] COMMAND [ARGS]...\n\n╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n│ --config              -c      TEXT  Config file path [default: config.yml]                                                                                                         │\n│ --install-completion                Install completion for the current shell.                                                                                                      │\n│ --show-completion                   Show completion for the current shell, to copy it or customize the installation.                                                               │\n│ --help                              Show this message and exit.                                                                                                                    │\n╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n╭─ Commands ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n│ check            Check whether the data in the database is consistent with the data in Meilisearch                                                                                 │\n│ refresh          Refresh all data by swap index                                                                                                                                    │\n│ start            Start meilisync                                                                                                                                                   │\n│ version          Show meilisync version                                                                                                                                            │\n╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n```\n\n### Start sync\n\nStart sync data from MySQL to Meilisearch:\n\n```shell\n❯ meilisync start\n2023-03-07 08:37:25.656 | INFO     | meilisync.main:_:86 - Start increment sync data from \"mysql\" to Meilisearch...\n```\n\n### Refresh sync\n\nRefresh all data by swap index:\n\n```shell\n❯ meilisync refresh -t test\n```\n\nBefore refresh, you need stop the sync process first to avoid data inconsistency.\n\n### Check sync\n\nCheck whether the data count in the database is consistent with the data in Meilisearch:\n\n```shell\n❯ meilisync check -t test\n\n```\n\n## Configuration\n\nHere is an example configuration file:\n\n```yaml\ndebug: true\nplugins:\n  - meilisync.plugin.Plugin\nprogress:\n  type: file\nsource:\n  type: mysql\n  host: 192.168.123.205\n  port: 3306\n  user: root\n  password: \"123456\"\n  database: beauty\nmeilisearch:\n  api_url: http://192.168.123.205:7700\n  api_key:\n  insert_size: 1000\n  insert_interval: 10\nsync:\n  - table: collection\n    index: beauty-collections\n    plugins:\n      - meilisync.plugin.Plugin\n    full: true\n    fields:\n      id:\n      title:\n      description:\n      category:\n  - table: picture\n    index: beauty-pictures\n    full: true\n    fields:\n      id:\n      description:\n      category:\nsentry:\n  dsn: \"\"\n  environment: \"production\"\n```\n\n### debug (optional)\n\nEnable debug mode, default is `false`, if you want to see more logs, you can set it to `true`.\n\n### plugins (optional)\n\nThe plugins are used to customize the data before or after insert to Meilisearch and the plugins is a list of python\nmodules.\n\nWhich is a python class with `pre_event` and `post_event` methods, the `pre_event` method is called before insert to\nMeilisearch, the `post_event` method is called after insert to Meilisearch.\n\n```python\nclass Plugin:\n    is_global = False\n\n    async def pre_event(self, event: Event):\n        logger.debug(f\"pre_event: {event}, is_global: {self.is_global}\")\n        return event\n\n    async def post_event(self, event: Event):\n        logger.debug(f\"post_event: {event}, is_global: {self.is_global}\")\n        return event\n```\n\nThe `is_global` is used to indicate whether the plugin instance is global, if set to `True`, the plugin instance will be\ncreated only once, otherwise, the plugin instance will be created for each event.\n\n### progress\n\nThe progress is used to record the last sync position, such as binlog position for MySQL.\n\n- `type`: `file` or `redis`, if set to file, another option `path` is required.\n- `path`: the file path to store the progress, default is `progress.json`.\n- `key`: the redis key to store the progress, default is `meilisync:progress`.\n- `dsn`: the redis dsn, default is `redis://localhost:6379/0`.\n\n### source\n\nSource database configuration, currently only support MySQL and PostgreSQL and MongoDB.\n\n- `type`: `mysql` or `postgres` or `mongo`.\n- `server_id`: the server id for MySQL binlog, default is `1`.\n- `database`: the database name.\n- `other keys`: the database connection arguments, MySQL see [asyncmy](https://github.com/long2ice/asyncmy), PostgreSQL\n  see [psycopg2](https://www.psycopg.org/docs/usage.html), MongoDB see [motor](https://motor.readthedocs.io/en/stable/).\n\n### meilisearch\n\nMeilisearch configuration.\n\n- `api_url`: the Meilisearch API URL.\n- `api_key`: the Meilisearch API key.\n- `insert_size`: insert after collecting this many documents, optional.\n- `insert_interval`: insert after this many seconds have passed, optional.\n\nIf nether `insert_size` nor `insert_interval` is set, it will insert each document immediately.\n\nIf you prefer performance, just set and increase `insert_size` and `insert_interval`. The insert will be made as long as\none of the conditions is met.\n\n### sync\n\nThe sync configuration, you can add multiple sync tasks.\n\n- `table`: the database table name or collection name.\n- `index`: the Meilisearch index name, if not set, it will use the table name.\n- `full`: whether to do a full sync, default is `false`.\n- `fields`: the fields to sync, if not set, it will sync all fields. The key is table field name, the value is the\n  Meilisearch field name, if not set, it will use the table field name.\n- `plugins`: the table level plugins, optional.\n\n### sentry (optional)\n\nSentry configuration.\n\n- `dsn`: the sentry dsn.\n- `environment`: the sentry environment, default is `production`.\n\n## License\n\nThis project is licensed under the\n[Apache-2.0](https://github.com/meilisync/meilisync/blob/main/LICENSE) License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flong2ice%2Fmeilisync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flong2ice%2Fmeilisync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flong2ice%2Fmeilisync/lists"}