gudusoft.gsqlparser
4.1.0.8
dotnet add package gudusoft.gsqlparser --version 4.1.0.8
NuGet\Install-Package gudusoft.gsqlparser -Version 4.1.0.8
<PackageReference Include="gudusoft.gsqlparser" Version="4.1.0.8" />
<PackageVersion Include="gudusoft.gsqlparser" Version="4.1.0.8" />
<PackageReference Include="gudusoft.gsqlparser" />
paket add gudusoft.gsqlparser --version 4.1.0.8
#r "nuget: gudusoft.gsqlparser, 4.1.0.8"
#:package gudusoft.gsqlparser@4.1.0.8
#addin nuget:?package=gudusoft.gsqlparser&version=4.1.0.8
#tool nuget:?package=gudusoft.gsqlparser&version=4.1.0.8
Trial edition. This package refuses SQL longer than 10,000 characters:
parse()returns-1andErrormessagereads "trial version can only process query with size less than 10000 characters". That is the trial limit, not a parse error in your SQL. Everything else behaves exactly as the full edition, which is available from https://www.sqlparser.com.
General SQL Parser .NET
Parse, analyze, modify and format SQL from 15 database vendors, in process, with no database connection.
Given a query, you get a parse tree you can walk: statement types, tables, columns, expressions, joins, CTEs, subqueries. You can rewrite the tree and generate SQL back out, or run the formatter over it.
Install
dotnet add package gudusoft.gsqlparser
Quick start
using gudusoft.gsqlparser;
using gudusoft.gsqlparser.nodes;
using gudusoft.gsqlparser.stmt;
var parser = new TGSqlParser(EDbVendor.dbvoracle);
parser.sqltext = "SELECT dept_id, COUNT(*) AS headcount "
+ "FROM employees e JOIN departments d ON e.dept_id = d.id "
+ "WHERE e.salary > 50000 GROUP BY dept_id";
if (parser.parse() != 0)
{
Console.WriteLine(parser.Errormessage);
return;
}
var select = (TSelectSqlStatement)parser.sqlstatements.get(0);
Console.WriteLine($"statement type: {select.sqlstatementtype}");
foreach (TTable table in select.tables)
Console.WriteLine($"table: {table.FullName}");
for (int i = 0; i < select.ResultColumnList.size(); i++)
Console.WriteLine($"column: {select.ResultColumnList.getResultColumn(i).Expr}");
Output:
statement type: sstselect
table: employees
table: departments
column: dept_id
column: COUNT(*)
parse() returns 0 on success. On failure it returns non-zero and
Errormessage explains why.
Supported databases
Pass the matching EDbVendor to the constructor:
| Database | EDbVendor |
Database | EDbVendor |
|---|---|---|---|
| Oracle | dbvoracle |
Snowflake | dbvsnowflake |
| SQL Server | dbvmssql |
Teradata | dbvteradata |
| PostgreSQL | dbvpostgresql |
Greenplum | dbvgreenplum |
| MySQL | dbvmysql |
Redshift | dbvredshift |
| DB2 | dbvdb2 |
Netezza | dbvnetezza |
| Hive | dbvhive |
Informix | dbvinformix |
| Impala | dbvimpala |
Sybase | dbvsybase |
| MDX | dbvmdx |
Target frameworks
net10.0 and netstandard2.0. The netstandard2.0 build covers .NET Framework
4.6.2+, Mono and Unity. (4.6.2, not 4.6.1: the netstandard2.0 build depends on
System.Text.Json 8.0.5, whose lowest .NET Framework asset is net462.)
Links
- Documentation: https://docs-dotnet.sqlparser.com
- Product site and full edition: https://www.sqlparser.com
- Sample programs: https://github.com/sqlparser/gsp_demo_dotnet
- Changelog: https://github.com/sqlparser/gsp_dotnet/blob/master/gsp_dotnet_core/doc/changes.txt
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 8.0.5)
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
TRIAL EDITION - SQL longer than 10,000 characters is rejected (parse() returns -1). Full edition: https://www.sqlparser.com/
Release 4.1.0.8
- [Oracle] Accept the IGNORE NULLS and RESPECT NULLS null-treatment
clauses after the closing parenthesis of a value-based window
function, before OVER, e.g.
LAG(var1, 1, var1) IGNORE NULLS OVER (ORDER BY ROWNUM),
LEAD(var1) RESPECT NULLS OVER (...),
FIRST_VALUE(var1) IGNORE NULLS OVER (...),
LAST_VALUE(var1) RESPECT NULLS OVER (...) and
NTH_VALUE(var1, 3) IGNORE NULLS OVER (...). Previously only the
FIRST_VALUE/LAST_VALUE inside-parenthesis IGNORE NULLS form was
accepted. RESPECT, LAG, LEAD and NTH_VALUE are unreserved keywords and
stay usable as ordinary identifiers.
- [Oracle] Support JSON_TABLE in the FROM clause, including the
COLUMNS list with value / EXISTS / FORMAT JSON query / NESTED PATH /
FOR ORDINALITY columns, wrapper clauses, and ON ERROR / ON EMPTY
handlers (ERROR/NULL/DEFAULT expr/EMPTY [ARRAY|OBJECT]), with or
without a table alias. The new keywords (JSON_TABLE, PATH, FORMAT,
JSON, WRAPPER, CONDITIONAL, UNCONDITIONAL, ORDINALITY) remain usable
as ordinary identifiers.
- [DB2] Accept a decimal literal with no leading digit directly after
an operator, e.g. decimal(...)+.005 or a>=.5. The lexer previously
glued the operator and the dot into one token.
- [demos] The sample programs now live in their own public repository,
github.com/sqlparser/gsp_demo_dotnet, and consume the published
gudusoft.gsqlparser package from nuget.org. The release ZIP includes
a demos.md pointer instead of vendored demo sources.
Demos: https://github.com/sqlparser/gsp_demo_dotnet