No error description provided though QSqlQuery::exec fails - c++

I get into the if block:
if ( !_query.exec( ) )
{
QString errdb = _db.driver()->lastError().databaseText();
QString errdrv = _db.driver()->lastError().driverText();
//...
but errdb and errdrv are empty.
Is there another way to check what went wrong?

You can get the error using QSqlQuery::lastError(), in your case _query.lastError().
Quote from the Qt documentation:
Returns error information about the last error (if any) that occurred
with this query.

What you need is _db.lastError().text().

Related

Sagemaker Pipelines - Unable to parse Pipeline Definition

I'm using Sagemaker Pipelines to chain together two consecutive ProcessingJobs. I'm getting a weird error when I call pipeline.upsert()
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the CreatePipeline operation: Unable to parse pipeline definition. Property 'null' with value 'null' is not of expected type 'String'
This is what my pipeline looks like:
step_process_data = ProcessingStep(
name='ProcessDataStep',
processor=script_processor,
code=os.path.join(BASE_DIR, "scripts/preprocess.py"),
job_arguments=job_arguments
)
step_split_data = ProcessingStep(
name='SplitDataStep',
processor=script_processor,
code=os.path.join(BASE_DIR, "scripts/split_data.py"),
job_arguments=job_arguments,
depends_on=[step_process_data]
)
pipeline = Pipeline(
name="DataPreperationPipeline",
steps=[step_process_data, step_split_data],
sagemaker_session=sagemaker_session
)
Any thoughts on what I am doing wrong or missing?
I ran into the same issue where my job_arguments were not all strings. I'd make sure all items in job_arguments are of the same type.
Not sure if you have all the objects are set up correctly can you please follow the below example and verify.
https://github.com/aws/amazon-sagemaker-examples/blob/main/sagemaker-pipelines/tabular/abalone_build_train_deploy/sagemaker-pipelines-preprocess-train-evaluate-batch-transform.ipynb

cassandraunit throws Dataset not found error

I am using cassandra-unit 3.0.0.1 from here but it is throwing dataset not found error
#Rule
public CassandraCQLUnit cassProvider = new CassandraCQLUnit(new ClassPathCQLDataSet("simple.cql","keyspaceNameToCreate"));
is there any other plugins i need to use or is it a bug in cassandra-unit?
EDITED
I have run my test in debug mode and found that the getInputDataSetLocation is returning null for me in ClassPathCQLDataSet.java
protected InputStream getInputDataSetLocation(String dataSetLocation) { //dataSetLocation: "simple.sql"
InputStream inputDataSetLocation = this.getClass().getResourceAsStream("/" + dataSetLocation); // inputDataSetLocation: null
//when i run test for cassandraunit-example app i get BufferedInputStream#924 but I am getting null here which is causing error
return inputDataSetLocation;
}
Please let me know if i am missing anything here. Thanks a ton

Unparsable MOF Query When Trying to Register Event

Update 2
I accepted an answer and asked a different question elsewhere, where I am still trying to get to the bottom of this.
I don't think that one-lining this query is the answer, as I am still not getting the required results (and multi-lining queries is allowed in .mof, as shown in the URLs in comments to the answer ...
Update
I rewrote the query as a one-liner as suggested, but still got the same error! As it was still talking about lines 11-19 I knew there must be another issue. After saving a new file with the change, I reran mofcomp and it appears to have loaded, but the event which I have subscribed to simply does not work.
I really feel that there is not enough documentation on this topic and it is hard to work out how I am meant to debug this - any help on this would be much appreciated, even if this means using a different more appropriate method.
I have the following .mof file, which I would like to use to register an event on my system :
#pragma namespace("\\\\.\\root\\subscription")
instance of __EventFilter as $EventFilter
{
Name = "Event Filter Instance Name";
Query = "Select * from __InstanceCreationEvent within 1 "
"where targetInstance isa \"Cim_DirectoryContainsFile\" "
"and targetInstance.GroupComponent = \"Win32_Directory.Name=\"c:\\\\test\"\"";
QueryLanguage = "WQL";
EventNamespace = "Root\\Cimv2";
};
instance of ActiveScriptEventConsumer as $Consumer
{
Name = "TestConsumer";
ScriptingEngine = "VBScript";
ScriptText =
"Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n"
"Set objFile = objFSO.OpenTextFile(\"c:\\test\\Log.txt\", 8, True)\n"
"objFile.WriteLine Time & \" \" & \" File Created\"\n"
"objFile.Close\n";
// Specify any other relevant properties.
};
instance of __FilterToConsumerBinding
{
Filter = $EventFilter;
Consumer = $Consumer;
};
But whenever I run the command mfcomp myfile.mof I am getting this error:
Parsing MOF file: myfile.mof
MOF file has been successfully parsed
Storing data in the repository...
An error occurred while processing item 1 defined on lines 11 - 19 in file myfile.mof:
Error Number: 0x80041058, Facility: WMI
Description: Unparsable query.
Compiler returned error 0x80041058
This error appears to be caused by incorrect syntax in the query, but I don't understand where I have gone wrong with this - is anyone able to advise?
There are no string concatenation or line continuation characters being used in building "Query". To keep it simple, you could put the entire query on one line.

rest-assured expected doesn't match

I try
#Test
public void testGetSingleUser() {
given().expect().
statusCode(200).contentType(ContentType.JSON).
body("_testingString", equalTo("got it")).when().
get("http://localhost:8080/getIt");
}
But always got this error message
java.lang.AssertionError : JSON path _testingString dosen't match.
Expected : "got it" got : [got it]
how to ignore "" and [] problem
Thanks
Note: This is untested code snippet but while looking at your error trace it may help you.
try
equalTo(Arrays.asList("got it"))
instead of
equalTo("got it")
When you receive a error saying, same like that:
JSON path total doesn't match.
Expected: 2000
Actual: <[2000]>
It means that your result(Actual:) is coming inside an array.
Hence, you should use a rest-assured-command(for example, hasItem) that verifies values 'inside an array'.
My code below illustrate a solution for this situation:
RestAssuredWebTestClient
.given()
.webTestClient(mockedWebClient)
.queryParam("cost", 1000)
.when()
.get(TEMPL_AGGREG_DATE)
.then()
.log()
.everything()
.statusCode(OK.value())
.body("_id", hasItem(project2.getStartDate()))
.body("total", hasItem((int)project2.getEstimatedCost()))
.body(matchesJsonSchemaInClasspath("contracts/aggregations/CostsGroupByStartDate.json"))
;

How Do You Call an MSSQL System Function From ADO/C++?

...specifically, the fn_listextendedproperty system function in MSSQL 2005.
I have added an Extended Property to my database object, named 'schemaVersion'. In my MSVC application, using ADO, I need to determine if that Extended Property exists and, if it does, return the string value out of it.
Here is the T-SQL code that does what I want. How do I write this in C++/ADO, or otherwise get the job done?
select value as schemaVer
from fn_listextendedproperty(default, default, default, default, default, default, default)
where name=N'schemaVersion'
Here's the code I tried at first. It failed with the error listed below the code:
_CommandPtr cmd;
cmd.CreateInstance(__uuidof(Command));
cmd->ActiveConnection = cnn;
cmd->PutCommandText("select value "
"from fn_listextendedproperty(default, default, default, default, default, default, default) "
"where name=N'schemaVersion'");
VARIANT varCount;
cmd->Execute(NULL, NULL, adCmdText);
...here are the errors I peeled out of the ADO errors collection. The output is from my little utility function which adds the extra text like the thread ID etc, so ignore that.
(Proc:0x1930, Thread:0x8A0) INFO : === 1 Provider Error Messages : =======================
(Proc:0x1930, Thread:0x8A0) INFO : [ 1] (-2147217900) 'Incorrect syntax near the keyword 'default'.'
(Proc:0x1930, Thread:0x8A0) INFO : (SQLState = '42000')
(Proc:0x1930, Thread:0x8A0) INFO : (Source = 'Microsoft OLE DB Provider for SQL Server')
(Proc:0x1930, Thread:0x8A0) INFO : (NativeError = 156)
(Proc:0x1930, Thread:0x8A0) INFO : ==========================================================
EDIT: Updated the call according to suggestions. Also changed "SELECT value AS schemaVer" to just "SELECT value".
EDIT: Changed the first parameter of Execute() to NULL per suggestion. This fixed my original problem, and I proceeded to the next. :)
Try specifying NULL rather than default for each parameter of fn_listextendedproperty. This should hopefully then execute without errors, just leaving you to retrieve the result as your next step.
I still have not figured out how to do this directly. To get on with my life, I wrote a stored procedure which called the function:
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[mh_getSchemaVersion]
#schemaVer VARCHAR(256) OUTPUT
AS
select #schemaVer = CAST( (select value from fn_listextendedproperty(default, default, default, default, default, default, default) where name=N'schemaVersion') AS varchar(256) )
return ##ROWCOUNT
...and then called thst sproc from my ADO/C++ code:
_CommandPtr cmd;
cmd.CreateInstance(__uuidof(Command));
cmd->ActiveConnection = cnn;
cmd->PutCommandText("mh_getSchemaVersion")_l
_variant_t schemaVar;
_ParameterPtr schemaVarParam = cmd->CreateParameter("#schemaVer", adVarChar, adParamOutput, 256);
cmd->GetParameters()->Append((IDispatch*)schemaVarParam);
cmd->Execute(NULL, NULL, adCmdStoredProc);
std::string v = (const char*)(_bstr_t)schemaVarParam->GetValue();
ver->hasVersion_ = true;
...which works, but I didn't want to have to deploy a new stored procedure.
So if anyone can come up with a solution to the original problem and show me how to call the system function directly from ADO/C++, I will accept that as the answer. Otherwise I'll just accept this.