Npgsql is the .NET data provider for Postgresql. It allows any program developed for .NET framework to access a Postgresql database server. It is implemented in 100% C# code. Postgresql versions since 9.0 are officially supported, others may work.
I'm trying to teach myself how to use ANTLR and their plsql grammar to (hopefully) get where I want to be but, as I said, it would be a lot nicer if I didn't have to go through all of that (or could, at least, eventually replace that).
I would assume that Npgsql does some sort of parsing at some level behind the scenes. I'm certainly not saying I think this request is "simple", but I would guess that there's at least a partial framework in place for some of the task.
Well, after a week of trying to get ANTLR to a place I could at least do some testing, I've given up for now. If a feature like I've described eventually becomes available in Npgsql (or if it's already there and I'm just not able to find it) or, if it's available in some other library somewhere that I haven't yet found, I'd be thrilled to hear about it. In the meantime, I'm just going to have to rebuild the SQL statements I need as I go.
I've posted a question on StackOverflow to this effect (.NET Library to Parse/Modify/Reconstruct SQL Statement) but, as I stated before, I'd certainly prefer to have it as a part of the Npgsql library I'm already using for most of my database communication anyway. If anyone else here has any suggestions or thoughts, I'd be glad to hear them. Thanks.
{[CollectionName = "Tables"]}[Data]()
and getting too few arguments error, will check docs.
CollectionName,NumberOfRestrictions,NumberOfIdentifierParts,Data,Function
MetaDataCollections,0,0,Table,Function
Restrictions,0,0,Table,Function
Databases,1,1,Function,Function
Tables,4,3,Function,Function
Columns,4,4,Function,Function
Views,3,3,Function,Function
Users,1,1,Function,Function
Indexes,4,4,Function,Function
IndexColumns,5,5,Function,Function
AdoDotNet.DataSource("Npgsql", "Server=redacted;Port=5432;User Id=redacted;Password=redacted;Database=redacted")
No, Npgsql doesn't come with a SQL parser - its job is only to take the SQL strings you provide it and send that to PostgreSQL. Parsing SQL is quite a complicated task as you've found out, especially if you start taking into accounts database-specific dialects...
I totally understand. I've kinda shelved that "side project" (parsing SQL statements) for now since I can't seem to get anything working correctly with ANTLR and I'm just having my application recreate the SQL statement completely instead of trying to manipulate its individual components.
That being said, for what I'm doing - extracting/parsing the SQL statement from a Crystal Reports document, updating one or more clauses, then push the modified SQL back into the document before the final report is generated/printed - it would still be nice to instead "simply" be able to access and modify that parse tree with the tools I'm already using (instead of banging my head against the ANTLR wall). As I said, I fully realize this is a fairly "one-off" type of usage situation in the grand scheme of things and there are other, "brute-force" methods of accomplishing the same goals.