This project is a fork of cqlengine with a number of changes to allow it to work in a baseplate application
- Major changes:
Remove support for polymorphic models
Remove the query evaluator method of defining query constraints
Switch from using a global connection object to passing a connection object to methods that interact with the database
Batch queries are handled by a Connection-like Batch object that is given as the conn argument to functions rather than using the Model.batch syntax of cqlengine
Example usage:
import uuid
from cassandra.cluster import Cluster
from cqlmapper import columns, connection, models
from cqlmapper.batch import Batch
from cqlmapper.connection import Connection as CQLMapperConnection
from cqlmapper.management import sync_table
class MyFirstModel(Model):
id = columns.UUID(primary_key=True, default=uuid.uuid4)
body = colums.Text()
cluster = Cluster()
session = cluster.connect("example")
conn = CQLMapperConnection(session)
sync_table(conn, MyFirstModel)
model_1 = MyFirstModel.create(conn, body="Hello World")
model_2 = MyFirstModel.create(conn, body="Hola Mundo")
# Batch queries can be used as a context manager where the batch query will
# be executed when exiting the context
with Batch(conn) as batch_conn:
MyFirstModel.create(batch_conn, body="Ciao mondo")
MyFirstModel.create(batch_conn, body="Bonjour le monde")
# Batch queries can also be created standalone in which case execute_batch
# can be called to execute the queries. Calls to execute will add the
# query to the batch
batch_conn = Batch(conn)
MyFirstModel.create(batch_conn, body="Hallo Welt")
MyFirstModel.create(batch_conn, body="Hei Verden")
>>> MyFirstModel.objects.count(conn)
4
>>> batch_conn.execute_batch()
>>> MyFirstModel.objects.count(conn)
6
>>> MyFirstModel.get(conn, id=model_1.id).text == model_1.text
True
>>> MyFirstModel.get(conn, id=model_2.id).text == model_1.text
False
Release files for reddit-cqlmapper 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| reddit_cqlmapper-0.3.0.tar.gz | 105.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| reddit_cqlmapper-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 250.9 kB
Release files / reddit_cqlmapper-0.3.0.tar.gz
| Download URL | reddit_cqlmapper-0.3.0.tar.gz |
|---|---|
| Size | 105.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69722be61c257cf0e8c3da35a6ed811e4cd5f6a3f661b3abf2a486ad17d4cb81
|
|
BLAKE2b-256 checksum How to use checksums |
086d747a1656753b7c962b493d12f3f062806da3f544ae80b712148f2fd7cdba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/47.3.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
|
Release files / reddit_cqlmapper-0.3.0-py3-none-any.whl
| Download URL | reddit_cqlmapper-0.3.0-py3-none-any.whl |
|---|---|
| Size | 145.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cfa34183b07fb2761d86e7a1346007dd06efa4a33c98d6ef9ae7b1394eb992f0
|
|
BLAKE2b-256 checksum How to use checksums |
7ba318b258a817212c735734d1343e06b08fd15f5bf17153a6c3e7b6279c8efd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.7.0 requests/2.25.1 setuptools/47.3.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
|