|
| 1 | +(migrate-from-crate-python)= |
| 2 | +# Migrate from `crate.client` |
| 3 | + |
| 4 | +In June 2024, code from the package [crate\[sqlalchemy\]] has been transferred |
| 5 | +to the package [sqlalchemy-cratedb]. For 80% of use cases, this will be |
| 6 | +a drop-in replacement with no noticeable changes. |
| 7 | + |
| 8 | +However, if you use CrateDB's special data types like `OBJECT`, `ARRAY`, |
| 9 | +`GEO_POINT`, or `GEO_SHAPE`, and imported the relevant symbols from |
| 10 | +`crate.client.sqlalchemy`, you will need to import the same symbols from |
| 11 | +`sqlalchemy_cratedb` from now on. |
| 12 | + |
| 13 | +## Upgrade procedure |
| 14 | + |
| 15 | +- Swap dependency definition from `crate[sqlalchemy]` to `sqlalchemy-cratedb` |
| 16 | + in your `pyproject.toml`, `requirements.txt`, or `setup.py`. |
| 17 | +- Adjust symbol imports as outlined below. |
| 18 | + |
| 19 | +### Symbol import adjustments |
| 20 | +```python |
| 21 | +# Previous import |
| 22 | +# from crate.client.sqlalchemy.dialect import CrateDialect |
| 23 | + |
| 24 | +# New import |
| 25 | +from sqlalchemy_cratedb import dialect |
| 26 | +``` |
| 27 | + |
| 28 | +```python |
| 29 | +# Previous import |
| 30 | +# from crate.client.sqlalchemy.types import ObjectArray, ObjectType, FloatVector, Geopoint, Geoshape |
| 31 | + |
| 32 | +# New import |
| 33 | +from sqlalchemy_cratedb import ObjectArray, ObjectType, FloatVector, Geopoint, Geoshape |
| 34 | +``` |
| 35 | + |
| 36 | +```python |
| 37 | +# Previous import |
| 38 | +# from crate.client.sqlalchemy.predicates import match |
| 39 | + |
| 40 | +# New import |
| 41 | +from sqlalchemy_cratedb import knn_match, match |
| 42 | +``` |
| 43 | + |
| 44 | + |
| 45 | +[crate\[sqlalchemy\]]: https://pypi.org/project/crate/ |
| 46 | +[sqlalchemy-cratedb]: https://pypi.org/project/sqlalchemy-cratedb/ |
0 commit comments