SQL query against a web page(or, advanced find) - sql

Suppose I have a table. Now, I'm interested in Getting Useful Data Easily. This means I'd rather not drop it into Excel and go through contortions, nor somehow get it into CSV and then into a DB, and then into SQL.
I'd like to be able to execute a SQL query directly against a table in HTML.
Has anyone heard of a tool like this before? I've never seen one.

There's no tool to query an HTML table with SQL as far as I know, but XQuery is a standard language you can use to find elements in an XML or XHTML source in a manner very similar to using SQL to query databases.

No, there is absolutely no tool that lets you run SQL queries against an HTML table... but you could easily write some simple JavaScript if you had a specific query you wanted done.

Related

Create a dynamic list of tables used by all the dashboards on the server

Is it possible to create something which extracts all the database/table names being used by multiple dashboards? We have a lot of old and new dashboards and we wanted to extract which tables are being used by the dashboards.
You can give this a try
https://help.qlik.com/en-US/governance-dashboard/Content/QV_GovDashboard/What.htm
It has a data lineage tab that can show you some stuff and I imagine help you to build your own custom solution
Im not sure that this is possible. Or at least not easy to achieve. In order to extract such info:
loop through all apps and extract the script
parse the Qlik script and find/extract all sql statements
parse these statements and extract the database/tables
Extracting the scripts is the easiest part here.
Isolating the sql statements might be doable but then parsing the sql will have to be done by something.
There is no complete Qlik script parser so potentially using string manipulations to extract the sql statements (imo depends on the sql complexity). (I havent lost hope to complete qlik-script-parser but have to spend a lot of time on it in order to complete it)
There are tools (like sqlformat chose output to be List DB Object) that can extract tables and fields but not sure if automation can be achieved.

Is there an existing piece of software that allows you to (easily) build queries throught a webpage?

I would like to build arbitrary queries to a database, by allowing the user to build queries "on the fly". For every object/table, being able to select its attributes, and then "building" the query (that would translate into a SQL statement) and finally launching it, all through a web interface.
The ticketing system "rt" does that, for example, and another example would be the http://gatherer.wizards.com/Pages/Advanced.aspx webpage.
I'm currently programming in rails but any existing solution that implements this (or something similar) would be welcome.
Just be careful when creating dynamically generated queries like this that will need to be executed via sp_executesql (example: ms sql server), etc..... make sure you cover all of your bases to ensure that your application isnt vulnerable to SQL injection attacks as this type of development will essentially get one in a lot of trouble if its done incorrectly.. I would recommend storing all queries in a table and only reading queries from this table to help isolate the queries that are being ran in your application. Just identify them with a label, and allow the EU to choose the label from a dropdown list control on the frontend.
Good luck and I'm not sure of any software that will help assist
Not quite sure what your use case is here but i would say check out the
Doctrine ORM ( Object Relational Mapper )
**Edit
After reading more and looking at the example. I would only suggest Doctrine for a large website.
Then use Doctrines DQL syntax with some javascript/jquery magic for the forms.
Note that the queries you're referencing aren't arbitrary: they're on a very specific problem domain, on a specific set of sql tables.
That said, if I were you I'd look into how people are building sql queries with javascript. Something like these:
http://code.google.com/p/django-querybuilder/
http://css.dzone.com/articles/sqlike-sql-querying-engine?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+zones%2Fria+(RIA+Zone)
http://thechangelog.com/post/4914956307/rel-arel-ported-to-node-js-with-some-changes
That'll at least get you a good idea of the underlying data structures.

Is there any framework for parsing a SQL-like query into its component parts?

I'm interested in writing a SQL-like query syntax for a CMS I work with. The idea would be that a CMS query could be written in a SQL-ish syntax, and I would convert that to execute through the CMS API.
There would be no field or table selection, so I need some way to get from this:
SELECT WHERE Something = 'something' AND (SomethingElse != 'something' OR AnotherThing == 'something')
Essentially then, I need some way to get the WHERE clauses grouped correctly based on their parentheticals and AND/ORs.
Is there some framework for doing this? Some example of when it's been done? I don't want to re-invent the wheel here, and I know someone else has to have done this in the past.
The answer is yes, there are many frameworks that work in an analog of SQL and convert to SQL. Linq and various Linq translators are a prime example. Knowing exactly which CMS you're working with, and thus which language and platform you're developing in, would be helpful. Some .NET ORMs that support code queries are:
NHibernate - allows use of a SQL-ish language called HQL in strings, or more code-based query construction using expression lists and Linq.
Linq2SQL - On its way out, but for your simpler applications it should be fine. The framework generates DAO classes that map between tables and your domain objects, and you can use coded Linq queries to work with the classes very much like the real tables.
And of course you can use good ol' vanilla ADO.NET with a string SQL query. This has numerous drawbacks, but if you want to have queries in your code, why not make them real SQL? If you wanted to hide your table structure, you could translate table names before submitting queries, so the SQL contained at the web layer (shudder) won't run against your DB.

SQL Query builder in Delphi

I need to give users the ability to build a simple SQL query against our database. Our application is written in Delphi.
I am assuming only moderate levels of knowledge by the user, but they need the ability to build a simple select statement to be able to query against a couple of tables. If I can make this easy for them, that would be most wondrous.
Does anyone know of a tool or a set of components that I can use to help the users build SQL SELECT statements...
I've used the DevExpress ExpressFilter control to allow users to specify SQL where constraints before.
I've come across FastQueryBuilder http://fast-report.com/en/products/visual-query-builder.html
and
OpenQueryBuilder http://fast-report.com/en/products/free-query-builder.html
(apparently differing versions of the same tool) at Fast-Report.
It looks like the right idea. Anyone have any experience with it?
I've used SimpleQuery for years and am quite happy with it. (http://devtools.korzh.com/eq/vcl/) It's not completely intuitive, but once you get the hang of it, you can present fields to the user from your database(s) and they can combine any series of them with ANDs and ORs to make very complex queries. You get a separate SQL window to save the resulting code. I make The resulting dataset available for printout with PrintDat! or to save as CSV data from the Woll2Woll Infopower grid that I use for display. I occasionally allow for XLS export too with XLSReadWrite. It's all quite automatic at this point. Just take the SimpleQuery example and mold that to your particular needs. You should be able to have something very usable in a day. There is a trial and an example free query builder standalone program that will give you an idea of the final look.
TMS Query Studio? Good value at 75 Euro..
Try EMS Advanced Query Builder.
is a powerful component suite for
Borland® Delphi® and C++ Builder®
intended for visual building SQL
statements for the SELECT, INSERT,
UPDATE and DELETE clauses. It allows
you to build new queries visually
and/or graphically represent the
existing queries in your own
applications. The suite includes
components for working with standard
SQL, MS SQL, InterBase/Firebird,
MySQL, PostgreSQL and many more
dialects. Advanced Query Builder
enables users to make up large and
complicated SQL queries with unions
and subqueries for different servers
without any knowledge of the SQL
syntax.
(source: sqlmanager.net)
(source: sqlmanager.net)
I think the most powerful one is ActiveQueryBuilder, which now included with Delphi IDE (Since 2007 I think)
(source: activequerybuilder.com)
I've written a couple of similar things in Delphi. It's easy enough to allow the user to pick table and column names by querying the metadata and using lists and tree views for display. The difficulty comes when trying to implement things like joins. I've never come up with a good interface for this, and in my experience neither have many of the major data tools players.
You may want to try this free builder:
GSC Visual Query Builder v.0.7
Visual Query Builder v.1.0
and some other in Torry:
http://www.torry.net/pages.php?id=546

LINQ to XML or SQL Server 2005 XML DML?

I'm writing an app that retrieves RSS feeds on a scheduled daily basis and saves the contents of each feed as XML Data in a SQL Server 2005 database. I want to display the aggregated items, sorted by date, for example, from the saved feed data in my app in Asp.Net GridViews.
My question is: should I use LINQ to XML to query the feed data, given that I already use LINQ to SQL in the app, or should I aggregate the data using a SQL query in a stored procedure, given that SQL Server 2005 has powerful XML-handling support?
I'm relatively new to both SQL Server 2005 and LINQ, so I can't really see what the relative advantages of either solution are, or whether they aren't really the same thing, effectively.
Well, I guess it really depends on where you prefer to write code. Personally I'm a lot more comfortable in C# than in T-SQL, so I'd do it in LINQ to XML (and indeed I've done exactly that for an RSS feed before now). It's likely to be pretty simple either way, but I don't see there's really much benefit in doing it in the database unless you're likely to have multiple clients which all want the same XML. Debugging etc tends (IMO) to be easier in C#, and unit tests are easier to write too.