Skip to content

Commit 4a06f99

Browse files
committed
Documentation: Improve page about migrating to sqlalchemy-cratedb
1 parent b6d9d1b commit 4a06f99

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

docs/migrate-from-crate-client.md

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,52 @@
11
(migrate-from-crate-python)=
22
# Migrate from `crate.client`
33

4+
## Introduction
45
In June 2024, code from the package [crate\[sqlalchemy\]] has been transferred
56
to the package [sqlalchemy-cratedb]. For 80% of use cases, this will be
67
a drop-in replacement with no noticeable changes.
78

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.
9+
With the release of `crate-1.0.0` in November 2024, the SQLAlchemy dialect was
10+
dropped from this package. See the "Upgrade procedure" section for further
11+
information.
1212

1313
## 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
14+
In order to continue using the CrateDB SQLAlchemy dialect, please install the
15+
`sqlalchemy-cratedb` package [^1].
16+
```shell
17+
pip install --upgrade sqlalchemy-cratedb
2618
```
2719

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-
```
20+
## Code changes
21+
If you are using CrateDB's special data types like `OBJECT`, `ARRAY`,
22+
`GEO_POINT`, or `GEO_SHAPE`, and imported the relevant symbols from
23+
`crate.client.sqlalchemy` before, you will need to adjust your imports
24+
to use `sqlalchemy_cratedb` from now on, as outlined below.
3525

26+
### Previous imports
3627
```python
37-
# Previous import
28+
from crate.client.sqlalchemy.dialect import CrateDialect
29+
from crate.client.sqlalchemy.types import ObjectArray, ObjectType, FloatVector, Geopoint, Geoshape
30+
from crate.client.sqlalchemy.predicates import match
3831
from crate.client.sqlalchemy.compiler import CrateDDLCompiler, CrateTypeCompiler
39-
40-
# New import
41-
from sqlalchemy_cratedb.compiler import CrateDDLCompiler, CrateTypeCompiler
4232
```
4333

34+
### New imports
4435
```python
45-
# Previous import
46-
# from crate.client.sqlalchemy.predicates import match
47-
48-
# New import
36+
from sqlalchemy_cratedb import dialect
37+
from sqlalchemy_cratedb import ObjectArray, ObjectType, FloatVector, Geopoint, Geoshape
4938
from sqlalchemy_cratedb import knn_match, match
39+
from sqlalchemy_cratedb.compiler import CrateDDLCompiler, CrateTypeCompiler
5040
```
5141

5242

5343
[crate\[sqlalchemy\]]: https://pypi.org/project/crate/
44+
[d2c42031f]: https://github.com/crate/cratedb-examples/commit/d2c42031f
5445
[sqlalchemy-cratedb]: https://pypi.org/project/sqlalchemy-cratedb/
46+
47+
[^1]: When applicable, please also update your project dependencies to use
48+
`sqlalchemy-cratedb` in your `pyproject.toml`, `requirements.txt`, or
49+
`setup.py` files, **instead** of using the previous `crate[sqlalchemy]`
50+
package. `sqlalchemy-cratedb` lists `crate` as a dependency and will
51+
automatically pull in the right version. A typical dependency update will
52+
look like [d2c42031f].

0 commit comments

Comments
 (0)