Skip to main content

MySQL / MariaDB source connector for moss-connectors.

Project description

moss-connector-mysql

MySQL / MariaDB source connector for Moss. Uses PyMySQL so it works against regular MySQL, MariaDB, and PlanetScale.

Install

pip install moss-connector-mysql

This installs pymysql automatically.

Usage

import asyncio
from moss import DocumentInfo
from moss_connector_mysql import MySQLConnector, ingest

async def main():
    source = MySQLConnector(
        host="localhost",
        user="root",
        password="secret",
        database="mydb",
        query="SELECT id, title, body FROM articles",
        mapper=lambda row: DocumentInfo(
            id=str(row["id"]),
            text=row["body"],
            metadata={"title": row["title"]},
        ),
        port=3306,
    )

    result = await ingest(
        source,
        project_id="your_project_id",
        project_key="your_project_key",
        index_name="articles",
    )
    print(f"copied {result.doc_count} rows")

asyncio.run(main())

Layout

src/
├── __init__.py      # re-exports MySQLConnector and ingest
├── connector.py     # MySQLConnector class
└── ingest.py        # ingest() - keep in sync with the other connector packages

Tests

pip install -e ".[dev]"
pytest tests/test_mysql.py -v                         # mocked, no network or DB needed
pytest tests/test_integration_mysql_moss.py -v -s     # live MySQL + Moss (requires MYSQL_URL, MOSS_PROJECT_ID, MOSS_PROJECT_KEY)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moss_connector_mysql-0.0.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moss_connector_mysql-0.0.1-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file moss_connector_mysql-0.0.1.tar.gz.

File metadata

  • Download URL: moss_connector_mysql-0.0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for moss_connector_mysql-0.0.1.tar.gz
Algorithm Hash digest
SHA256 80b6c67c68ebd8e2a0f73f4346b9286de7f1cdf6e3d10f2f9775e9b70f8adfb2
MD5 886e30bc505aef0f3ecb13f469a5849d
BLAKE2b-256 7d7b1f15c76a46cf26ef73afcd8fcfdbfe9edf9afda861bc9f6c031a94b1fb61

See more details on using hashes here.

File details

Details for the file moss_connector_mysql-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for moss_connector_mysql-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 779941693b8c602606e95f7200ad20b010511b1882a48f3ab1e1d70ad929bb69
MD5 af7b8bbf4fd5130d42bcd072b955eddd
BLAKE2b-256 eba915edd56bdd49f204d9d4e04a784aba47d777440f3a767c4461095058ea6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page