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.
Related
Refer the following code:
def parse(height_id):
driver2=webdriver.Firefox()
driver2.get(height_id)
block_details_web_element=driver2.find_element_by_xpath('//*[#id="__next"]/div[3]/div/div[3]/div[1]/div/div')
print (block_details_web_element)
print(block_details_web_element.text)
print(" --- BLOCK PARSED SUCCESSFULLY! ---\n")
driver2.quit()
#the following parts are outside the function:
p = Pool(4)
records = p.map(parse, height_list_on_each_page2) #height_list_on_each_page2 is a list of URLs.
p.terminate()
p.join()
(Eg. of a typical URL: https://www.blockchain.com/btc/block/000000000000000000028e473f1c95060a63100c9861525105b1f5ced81a7fa0 )
Now, this works fine, but takes huge time. So, I planned to put the statement driver2=webdriver.Firefox() outside the parse function, so that I don't re-create the instance of WebDriver each time I'm calling the function. [And I also removed the statement driver2.quit() from this function]. This is saving time, however, almost half of the times the print statment print (block_details_web_element) is returning None as output.
I doubt that the find_elements_by_xpath method is not working correctly. Is this because of multi-processing that I am using?
Any insight, why this is happening? Please suggest a solution.
EDIT : (this is the error)
(https://www.dropbox.com/s/1yvknbdg9wefuwy/selenium.jpeg?dl=0)
Here is the simple code
vars.put("str" , "${__time(dd/mm/yyyy HH:MM:SS)}");
log.info("${str}");
I am expecting to see the value of str in logs but I am getting ${str}. I am validating it because I have to assign the current time to a variable and later want to use it in script. But I am not getting the value stored in str.
try as follows using vars.get:
vars.put("str" , "${__time(dd/mm/yyyy HH:MM:SS)}");
log.info("str " + vars.get("str"));
I wouldn't recommend inlining functions and/or variables into Beanshell script as you may face syntax error issues, i.e. type mismatch if the value has quotation marks.
So either use log.info(vars.get("str")); or use Debug Sampler and View Results Tree listener combination to see JMeter variables values.
More information: How to Debug your Apache JMeter Script
I want to run a Bigquery SQL query using insert method.
I ran the following code just like so:
JobConfigurationQuery = Google::Apis::BigqueryV2::JobConfigurationQuery
bq = Google::Apis::BigqueryV2::BigqueryService.new
scopes = [Google::Apis::BigqueryV2::AUTH_BIGQUERY]
bq.authorization = Google::Auth.get_application_default(scopes)
bq.authorization.fetch_access_token!
query_config = {query: "select colA from [dataset.table]"}
qr = JobConfigurationQuery.new(configuration:{query: query_config})
bq.insert_job(projectId, qr)
and I got an error as below:
Caught error invalid: Job configuration must contain exactly one job-specific configuration object (e.g., query, load, extract, spreadsheetExtract), but there were 0:
Please let me know how to use the insert_job method.
I'm not sure what client library you're using, but insert_job probably takes a JobConfiguration. You should create one of those and set the query parameter to equal your JobConfigurationQuery you've created.
This is necessary because you can insert various jobs (load, copy, extract) with different types of configurations to this one API method, and they all take a single configuration type with a subfield that specifies which type and details about the job to insert.
More info from BigQuery's documentation:
jobs.insert documentation
job resource: note the "configuration" field and its "query" subfield
I have a stored procedure in Sybase which I can invoke from my favourite SQL client like this:
exec getFooBar #Foo='FOO', #Bar='BAR'
It returns a table of results, so its like a query. It has actually many parameters, but I only want to call it with Foo and sometimes with Foo and Bar specified.
Sybase is ASE 15.0, I am using jConnect 6.0.5.
I can invoke this using a PreparedCall if I specify only the first parameter:
CallableStatement cs = conn.prepareCall("{call getFooBar(?) }");
cs.setString(1,"FOO");
However I can't use the #Foo notation to pass my params:
conn.prepareCall("{call getFooBar #Foo='FOO' }");
conn.prepareCall("call getFooBar #Foo='FOO' ");
conn.prepareCall("{call getFooBar #Foo=? }"); // + setString(1,'FOO')
In all these cases I get exception from the DB telling me that the Foo parameter is expected:
com.sybase.jdbc3.jdbc.SybSQLException: Procedure getFooBar expects
parameter #Foo, which was not supplied
Ideally I'd like to do this with Spring JdbcTemplate or SimpleJdbcCall, but with those I could not even get to the point where I could with plain old JDBC.
So to summarize, I'd like to avoid ending up with:
{ call getFooBar(?,null,null,null,null,null,?,null,null) }
Is that possible using JDBC or better Spring?
Not the most efficient solution, but, have you tried using the plain Statement itself with EXEC.
eg.
String mySql = "EXEC getFooBar #Foo='FOO', #Bar='BAR'";
ResultSet rs = conn.getConnection().createStatement().executeQuery(mySql);
Based on this and this, I'm doing the following to get the SQL enerated by Entity Framework 5.0
var query = from s in db.ClassesDetails
where s.ClassSet == "SetOne"
orderby s.ClassNum
select s.ClassNum;
var objectQuery = (System.Data.Objects.ObjectQuery)query; // <= problem!
var sql = objectQuery.ToTraceString();
However on the second line I get the following exception:
Unable to cast object of type 'System.Data.Entity.Infrastructure.DbQuery`1[System.Int16]' to type 'System.Data.Objects.ObjectQuery'.
Did something change since those SO answers were posted? What do I need to do to get the queries as strings? We're running against Azure SQL so can't run the usual SQL profiler tools :(
ObjectQuery is created when you are using ObjectContext. When you are using DbContext it uses and creates DbQuery. Also, note that this is actually not a DbQuery but DbQuery<T>. I believe that to display SQL when having DbQueries you can just do .ToString() on the DbQuery instance so no cast should be required. Note that parameter values will not be displayed though. Parameter values were added to the output very recently in EF6 - if you need this you can try the latest nightly build from http://entityframework.codeplex.com