Collection' object is not callable. If you meant to call the 'update' method on a 'Collection' object it is failing because no such method exists - pymongo

I am trying to save a record into mongo db using pymongo. I have the script to update the collection if it exists or insert one record. This snippet works when run interactively, but when I try to do the same from docker, the script fails with the error - Collection' object is not callable. If you meant to call the 'update' method on a 'Collection' object it is failing because no such method exists.
def store_failed_cbsd(id,data,collection_name,mongo_client):
output_content = {'_id' : id,'data' : [data]}
key = {'_id': id}
mongo_client.get_database()[collection_name].update(key,
output_content, upsert=True)
PyMongo Version - 4.1.1
What am I missing?

update() was deprecated for pymongo 4. Use update_many() or update_one() instead.
https://pymongo.readthedocs.io/en/stable/migrate-to-pymongo4.html#collection-update-is-removed

Related

adding new document to CouchDb using ArmChair throws exception Object reference not set to an instance of an object

Iam using couch-db version 2.2.0
and I want to make crud operations on couchdb database using .Net
so I installed Armchair.Core Nuget Package version 0.11.2
and in order to add d a new document I, followed the code that is mentioned in
not finished wiki yet
https://bitbucket.org/dboneslabs/arm-chair/wiki/main-api/session-api.md
Database mydatabase = new Database("TestDb",newConnection("http://localhost:5984"));
using (var session = mydatabase.CreateSession())
{
var author = new Person("Jone");
session.Add(author);// NOTE: If no Id has been assigned before the instance is added to the Session, then ArmChair will assign it. After the object is committed to the database, the revision will then be set onto the instance
session.Commit();
}
but I still getting the error
Object reference not set to an instance of an object.
also mydatabase variable mentioned in previous code has values null for Connection and DataBase Parameters even though i passed them in the constructor as it doesn't connect to couchdb database at all and never tries to create database TestDb
any help please ,are there any wrong calls in my code
ArmChair connects to an existing database and does not create one.
if you want to create a database, have a look a look at the sample application, in the Autofac registration there is a method which ensures that there is a database created.
https://bitbucket.org/dboneslabs/arm-chair/src/bd4e70d6c51d8b45cfb89eb65ecf81a4ecefb691/samples/todo/Todo.Service/Infrastructure/Modules/DataAccessModule.cs#lines-62
its not the pretty-est of code but works.

How to sert autoReorg=false

Where can I specify autoReorg=false.
I see that by default autoReorg is set to true.
Attempting to set the property in a properties file or command line results in an error:
Unexpected error running Liquibase: Unknown parameter: 'autoReorg'
I got the above error message using Liquibase 3.5.3 and 3.6.2.
I need to be able to specify autoReorg=false when working with DB2.
Its currently not possible to set this via properties or commandline. You must pass it as a java property.
https://liquibase.jira.com/browse/CORE-3257
Problem It is not possible to turn off automatically generated reorg
statements for DB2 using liquibase properties. This is because in
Main.java, there is no field for the property 'autoReorg', and hence
liquibase throws a CommandLineParsingException in
parsePropertiesFile().
Expected result Reorg statements should not be generated for DB2 when
the liquibase property file contains the property autoReorg=false or
when this property is passed via the command line.
Workaround A workaround is to set the property
-Dliquibase.autoReorg=false as a java property.

Groovy Sql Execute Statement won't accept closures

I have a statement:
sqlInstance.execute(executeString){
dummy, realList->
debug("Real LIst: "+realList)
}
which fails with 'Invalid column type'
But:
def bool = sqlInstance.execute(executeString)
works. If I print bool, it prints as 'true'.
For reference:
executeString = "select distinct channel_id from guide_sched"
For some reason, the closure isn't working for the execute method in groovy's Sql, although I've checked the documentation and it's supposed to.
It looks like the first environment I was testing on ran Groovy 2.4 and the second runs Groovy 2.1. The execute statement I was using didn't exist until after 2.1
Instead, I used the .rows() function to return a GroovyRowResult which I parsed for the information I needed, instead of accessing it directly in the .execute() closure.

How can I reference a TestCase property from an AMF request TestStep script in soapUI?

I have a Test Case called "testCaseOne"
It contains three Test Steps:
"AMFrequestOne"
"propertyTransfer"
"AMFrequestTwo"
"AMFrequestOne" creates a database object.
"propertyTransfer" sends the ResponseAsXml to a temporary property in "testCaseOne" called "tempProp".
I need to reference "tempProp" in a script inside of "AMFrequestTwo"
I've tried the following
def temp = testRunner.testCase.getPropertyValue( "tempProp" )
but I get the error "No such property: testRunner for class: Script6" (number increments with tries)
Is this because in an AMF request "Script is invoked with log, context, parameters and amfHeaders variables" and testRunner is not recognized?
I know it seems odd, but is it possible to do this? I'm unable to use a specific xpath property transfer between the two AMF Requests as it's possible for the structure to change and I'm not always looking for the same node.
Used
def temp = context.testCase.getPropertyValue( "tempProp" )
instead of
def temp = testRunner.testCase.getPropertyValue( "tempProp" )
and this works fine.

Updating models in a Doctrine Migration

I'm trying to update a model in the context of a Doctrine_Migration. Calling save() on the object doesn't seem to update the database. I also tried calling execute() a Doctrine_Query in the context of a Doctrine_Migration. I tried running getSqlQuery() on the query object and I get a valid query that works if executed in a mysql console, however if I just run the migration normally I get no errors and the execute() doesn't seem to do anything.
How can successfully execute() a query in the context of a migration?
$res = Doctrine_Query::create()->update('FooBar')->set('colFoo', '?', 'valBar')->execute();
This should do the trick