Skip to content

Commit 9646e80

Browse files
amotlsimonprickett
andcommitted
Documentation: Add section about migration from crate.client
Co-authored-by: Simon Prickett <[email protected]>
1 parent 5f8d4cb commit 9646e80

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

docs/index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ pandas, Dask, and many other libraries and applications connecting to
2525
CrateDB from the Python ecosystem. It is verified to work with CPython, but
2626
it has also been tested successfully with `PyPy`_.
2727

28+
.. note::
29+
30+
If you are upgrading from ``crate[sqlalchemy]`` to ``sqlalchemy-cratedb``,
31+
please read this section carefully.
32+
33+
.. toctree::
34+
:titlesonly:
35+
36+
migrate-from-crate-client
37+
38+
2839

2940
************
3041
Introduction

docs/migrate-from-crate-client.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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

Comments
 (0)