how do i implement regular expression in amazon simpledb - amazon-simpledb

I have data stored in this format in amazon simpledb
source code success
fa.php 987439aa true
ga.php aa84892 false
how do i wrtie this type of query in simpledb
select * from domain_name where source = 'fa.php'
and code='ANy thing' and success = 'true'
How do i write code part in the above query

You can run this select query to achieve you result -
**select * from domain_name where source = 'fa.php' and code is not null and success = 'true'**
You can not add/update/delete data using Amazon simple DB query.

Related

Denodo Json Source and Base View: how to make VQL more traditional SQL syntax

I have a web service api
In Denodo, I have virtualized the following api:
https://delphi.cmu.edu/epidata/fluview/?regions=nat&epiweeks=201501,201601,201701
as
https://delphi.cmu.edu/epidata/fluview/?regions=#{regions}&epiweeks=#{epiweeks}
This allows us, in Denodo, to write the following:
Select * from bv_fluview where epiweeks = '201501,201601,201701' and regions = 'nat'
Is there any way where the query could be written in a more traditional way such as:
Select * from bv_fluview where epiweeks in ('201501','201601','201701') and regions = 'nat'
I am relatively new to Denodo.
Thanks,
Dan
In Denodo, you can use the IN clause to check if a value is present in a list
SELECT *
FROM bv_fluview
WHERE epiweeks IN ('201501','201601','201701')
AND regions = 'nat'
This would return the same result as your original query but with a more conventional syntax for the IN operator.

Getting error when using timestamp index in dask with snowflake

I am trying read tables from snowflake and use merge_asof to perform point in time correct join. Here is the corresponding code:
next_failure = dd.read_sql_table('vm_next_failure', conn_url, index_col='ts')
errors = dd.read_sql_table('vm_errors', conn_url, index_col='ts')
ndf = dd.merge_asof(next_failure, errors, left_index=True, right_index='ts', by="machineid", suffixes=("_l", "_r"), allow_exact_matches=False)
Here is the error I get:
ProgrammingError: (snowflake.connector.errors.ProgrammingError) 252004: Failed processing pyformat-parameters: 255001: Binding data in type (timestamp) is not supported.
[SQL: SELECT vm_errors.ts, vm_errors.machineid, vm_errors.error1, vm_errors.error2, vm_errors.error3, vm_errors.error4, vm_errors.error5
FROM vm_errors
WHERE vm_errors.ts >= %(ts_1)s AND vm_errors.ts <= %(ts_2)s]
[parameters: {'ts_1': Timestamp('2015-01-01 06:00:00'), 'ts_2': Timestamp('2016-01-01 05:00:00')}]
(Background on this error at: http://sqlalche.me/e/13/f405)
Any thoughts on how to workaround this?
Looks like you need to replace Timestamp with TO_Timestamp.
Please run the following query in the snowflake:
select TO_Timestamp('2016-01-01 05:00:00')

F#- How can we validate the whole schema of API response using HttpFs.Client or Hopac?

I have a test where after getting a response I would like to validate the entire schema of the response (not individual response node/value comparison).
Sample test:
[<Test>]
let howtoValidateSchema () =
let request = Request.createUrl Post "https://reqres.in/api/users"
|> Request.setHeader (Accept "application/json")
|> Request.bodyString """{"name": "morpheus",
 "job": "leader"}"""
|> Request.responseAsString
|> run
Is there a way that I can save my expected Schema somewhere and once I get the response I do the comparison to check that response has same number of nodes (neither less nor more than expected schema)?
I am ok to opt for other libs like FSharp.Data if we there is no direct way in HttpFs.Client. I looked at FSharp.Data (https://fsharp.github.io/FSharp.Data/library/JsonProvider.html) but not able to seek how it meets the requirements where the schema comparison needs to be done with the savedExpectedSchemaJson=ResponseJson.
You can use Newtonsoft.Json.Schemato validate schemas:
open Newtonsoft.Json.Schema
open Newtonsoft.Json.Linq
let schema = JSchema.Parse expectedSchema
let json = JObject.Parse responeJson
let valid = json.IsValid schema
However this assumes you have a schema predefined somewhere. If you don't have such schema is best to use the JsonProvider who can infer it for you.
Run the call manually and save the result in a sample.json file and create a type using the JsonProvider:
type ResponseSchema = JsonProvider<"sample.json">
and you can use this type to parse any new content based on the sample (provided that the sample is a representative.
ResponseSchema.parse response
This won't validate the schema but will try to meet as best as it can given the input.

Ruby on Rails Active Record Query - counting records

Hi I'm new to rails and developing an application to pull results from database in preparation for charting. I have the following code in my controller:
#statistic = OutstandingWorkIndex.find_by_sql ["SELECT Result_Set.Set_Code, Request.Specimen_Number ,
DATEDIFF('hh',Result_Set.Date_Time_Booked_In,current_timestamp) as HrsIn FROM iLabTP.Outstanding_Work_Index, iLabTP.Result_Set Result_Set, iLabTP.Request
WHERE Outstanding_Work_Index.Request_Row_ID = Result_Set.Request_Row_ID and Outstanding_Work_Index.Request_Row_ID = Request.Request_Row_ID and Result_Set.Set_code=?
order by Result_Set.Date_Time_Booked_In DESC", params[:set_code].upcase]
What I'd like to do is count the number of records returned in addition to the object from above which I then use to create and XML stream of paired values or use the google charts java script api in the view.
Do I need to issue commands like:
#statistic = OutstandingWorkIndex.find_by_sql ["SELECT Result_Set.Set_Code, Request.Specimen_Number ,
DATEDIFF('hh',Result_Set.Date_Time_Booked_In,current_timestamp) as HrsIn
FROM iLabTP.Outstanding_Work_Index, iLabTP.Result_Set Result_Set, iLabTP.Request
WHERE Outstanding_Work_Index.Request_Row_ID = Result_Set.Request_Row_ID and Outstanding_Work_Index.Request_Row_ID = Request.Request_Row_ID and Result_Set.Set_code=?
order by Result_Set.Date_Time_Booked_In DESC", params[:set_code].upcase].**count**
And if so does this result in the query being reissued?
Thanks
You should do:
#size = #statistic.size
It's well explained here.

how to insert rdf into virtuoso via jena?

After i generate my rdf triple.I want to insert them into Virtuoso triple Store via Jena.
....
model.write(System.out,"RDF/XML");
....
url = "jdbc:virtuoso://localhost:1111";
VirtGraph set = new VirtGraph (url, "dba", "dba");
Query sparql = QueryFactory.create("?????");
VirtuosoQueryExecution vqe = VirtuosoQueryExecutionFactory.create (sparql, set);
vqe.exec();
How can i do ?
The documentation for the Virtuoso Jena Provider includes a sample program VirtuosoSPARQLExample8 demonstrating how to insert triples into a graph.

Resources