Metadata-Version: 2.4
Name: moss-connector-mysql
Version: 0.0.1
Summary: MySQL / MariaDB source connector for moss-connectors.
Author-email: "InferEdge Inc." <contact@moss.dev>
License: BSD-2-Clause
Project-URL: Homepage, https://github.com/usemoss/moss
Project-URL: Repository, https://github.com/usemoss/moss
Project-URL: Source, https://github.com/usemoss/moss/tree/main/packages/moss-data-connector/moss-connector-mysql
Keywords: moss,connectors,mysql,mariadb,ingest,etl
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Requires-Python: <3.15,>=3.10
Description-Content-Type: text/markdown
Requires-Dist: moss>=1.1.1
Requires-Dist: pymysql>=1.1
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
Requires-Dist: python-dotenv>=1.0.0; extra == "dev"
Requires-Dist: ruff>=0.5.0; extra == "dev"

# moss-connector-mysql

MySQL / MariaDB source connector for Moss. Uses [PyMySQL](https://github.com/PyMySQL/PyMySQL) so it works against regular MySQL, MariaDB, and PlanetScale.

## Install

```bash
pip install moss-connector-mysql
```

This installs `pymysql` automatically.

## Usage

```python
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

```bash
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)
```
