I am in a situation where I need to convert my dynamically generated SQL Server query to Mongo DB query. Is there any tool/plugin/nuget package available that takes sql server query as input and outputs mongodb query(just like what is done in "www.querymongo.com")?
No
I would add than you don't send interpreted language (sql) than you can adapt according to the database server, but you use a proprietary API :
http://docs.mongodb.org/ecosystem/tutorial/use-linq-queries-with-csharp-driver/
Have created a JS for creating the Mongo queries dynamically, based on the operators selected.
Related
I am using the WPForms Pro version that stored the entries into a database. I found out that WPForms stored the data into my database as JSON into the fields column of wp_entries table.
I need to further process this data into reports and I would love this data to be available as standard SQL table.
Does anyone know how to convert this JSON code into a SQL output using SQL code? I have tried JSON_TABLE function but I'm a bit unfamiliar with that logic.
Backend is MySQL / MariaDB.
My JSON data looks something like this:
{"5":{"name":"Locate cost","value":"0.90","id":5,"type":"number"},"3":{"name":"Ticker","value":"IDAI","id":3,"type":"text"}
Thanks!
I'm trying to use Prometheus to monitor my MySQL database but can't seem to find an area to add SQL queries. For example, I'd like to run a SQL query which returns a value and then add that value to the graph/send an alert. Is there a way to have Prometheus send SQL queries and retrieve the output?
Thank you
https://github.com/chop-dbhi/prometheus-sql will allow queries to be run against any SQL database that can then be scraped as metrics.
All of the examples I've found show how to use query by sql statement, as: 'connection.query("select * from my_table",...)', but I want to do it without sql statement, but with store procedure.
I found something about 'db-mysql' that supplies this option but I didn't success installing it.
I don't want to use sql statement in my code.
I want to select, update etc. by stored procedures in my mysqldatabase (like C#).
How can I do it?
Checkout http://sequelizejs.com/ it is a node compatible orm which allows you to easily interface with sql without needing to use sql statements.
I'm new to Talend. I want to make a script that transform my data (using an sql query) from a database and insert them to an other one.
Could you help me please with the list of components that I should use ? any tutorial ?
Thank you
Talend has many database specific components. You will find input and output components for all databases. input components are those which enables you to read data from database and bring it to talend and output components are those which allows you to write/insert data to database.
for example if your source and target are both oracle then -
toracleinput will be for reading from oracle db - (you have to mention connection details, sql query and schema for this component).
toracleoutput will be for inserting this data back to oracle database table. Here again you have to mention connection details, target table name, type of operation etc..
finally you have to connect flow of data from input to output component and if you need any intermediate transformations, joins etc you have to user other talend components in between like tMap etc..
I am creating an ETL in SSIS in which I which I want my data source to be a restricted query, like select * from table_name where id='Variable'. This variable is what I defined as User created variable.
I do not understand how I can have my source query interact with the SSIS scoped Variable.
The only present options are
Table
Table from variable
SQL Command
SQL command from a variable
What I want is to have a SQL statement having a variable as parameter
Simple. Choose SQL command as the Data Access Mode. Enter your query with a question mark as a parameter placeholder. Then click the Parameters button and map your variable to Parameter0 in the Set Query Parameters dialog:
More information is available on MSDN.
An inferior alternative to #Edmund's approach is to use an Expression on another Variable to build your string. Assuming you have #[User::FirstName] already defined, you would then create another variable, #[User::SourceQuery].
In the properties for this variable, set EvaluateAsExpression to True and then set an Expression like "SELECT FirstName, LastName, FROM Person.Person WHERE FirstName = '" + #[User::FirstName] +"'" The double quotes are required because we are building an SSIS String.
There are two big reasons this approach should not be implored.
Caching
This approach is going to bloat your plan cache in SQL Server with N copies of essentially the same query. The first time it runs and the value is "Edmund" SQL Server will create an execution plan and save it (because it can be expensive to build them). You then run the package and the value is "Bill". SQL Server checks to see if it has a plan for this. It doesn't, it only has one for Edmund and so it creates another copy of the plan, this time hard coded to Bill. Lather-rinse-repeat and watch your available memory dwindle until it unloads some plans.
By using the parameter approach, when the plan is submitted to SQL Server, it should be creating a parameterized version of the plan internally and assumes that all parameters supplied will result in equal costing executions. Generally speaking, this is the desired behaviour.
If your database is optimized for ad-hoc workload (it's a setting turned off by default), that should be mitigated as every plan is going to get parameterized.
SQL Injection
The other big nasty you will run into with building your own string is that you open yourself up to SQL Injection attacks or at the least, you can get runtime errors. It's as simple as having a value of "d'Artagnan." That single quote will cause your query to fail resulting in package failure. Changing the value to "';DROP TABLE Person.Person;--" will result in great pain.
You might think it's trivial to safe quote everything but the effort of implementing it consistently everywhere you query is beyond what your employer is paying you. All the more so since there is native functionality provided to do the same thing.
When using OLEDB Connection manager (with SQL Server Native Client 11.0 provider in my case) you can catch an error like this:
Parameters cannot be extracted from the SQL command. The provider
might not help to parse parameter information from the command. In
that case, use the "SQL command from variable" access mode, in which
the entire SQL command is stored in a variable.
So you need to explicitly specify database name in OLEDB Connection manager properties. Otherwise SQL Server Native Client can use different database name then you mean (e.g. master in MSSQL Server).
For some cases you can explicitly specify database name for each database object used in query, e.g.:
select Name
from MyDatabase.MySchema.MyTable
where id = ?