You can use `DataModel.objects.using().create()` or use another model for this purpose. See the ContextQuery utility:
https://docs.datastax.com/en/developer/python-driver/3.23/cqlengine/connections/#context-manager https://docs.datastax.com/en/developer/python-driver/3.23/api/cassandra/cqlengine/query/#cassandra.cqlengine.query.ContextQuery On Sun, May 17, 2020 at 3:17 PM Bimal Gangawal <bimalganga...@gmail.com> wrote: > But I am not able to save the row here using > datamodel.objects.using(keyspace="tb1").save() > > What is the preferred alternative to achieve this ? > > On Sat, May 16, 2020, 7:37 AM Alan Boudreault < > alan.boudrea...@datastax.com> wrote: > >> Hello Bimal, >> >> Due to some internal limitations, you can only switch the keyspace on the >> fly of a ModelQuerySet, not a model instance. This should work: >> >> DataModel.objects.using(keyspace="tb1") >> >> Alan >> >> On Fri, May 15, 2020 at 5:00 AM Bimal Gangawal <bimalganga...@gmail.com> >> wrote: >> >>> Hi, >>> >>> I am new to cassandra and using python to insert data into cassandra >>> (cassandra-driver==3.23.0). >>> >>> https://docs.datastax.com/en/developer/python-driver/3.23/cqlengine/connections/ >>> In >>> this document i found that we can use using() method to change the keyspace >>> and connection on the fly but while doing the same i ended up with below >>> error >>> >>> i have a table DataModel() class through which i have defined the table >>> as ORM >>> datamodel = DataModel() >>> .... >>> datamodel.using(keyspace="tb1").save() >>> >>> TypeError: using_setter() got an unexpected keyword argument 'keyspace' >>> >>> >>> After looking at the source i found that using() only takes connection and >>> not keyspace as parameter. >>> >>> What is the alternative to achieve this? >>> >>> Please correct me if i am wrong. >>> Thanks >>> >>> >>> -Bimal >>> >>> >> >> -- >> Alan Boudreault >> e. alan.boudrea...@datastax.com >> w. www.datastax.com >> >> -- Alan Boudreault e. alan.boudrea...@datastax.com w. www.datastax.com