SQLParser 3.0.21
dotnet add package SQLParser --version 3.0.21
NuGet\Install-Package SQLParser -Version 3.0.21
<PackageReference Include="SQLParser" Version="3.0.21" />
paket add SQLParser --version 3.0.21
#r "nuget: SQLParser, 3.0.21"
// Install SQLParser as a Cake Addin #addin nuget:?package=SQLParser&version=3.0.21 // Install SQLParser as a Cake Tool #tool nuget:?package=SQLParser&version=3.0.21
SQLParser
This C# library provides a SQL parser and lexer implementation using ANTLR. It allows you to parse SQL queries into an abstract syntax tree (AST) and perform various operations on the parsed queries.
Features
- Lexical analysis: Tokenizing SQL queries into individual tokens.
- Syntactic analysis: Parsing SQL queries into an abstract syntax tree.
- Query manipulation: Modifying and transforming the parsed SQL queries.
- Query analysis: Extracting metadata and information from SQL queries.
Installation
You can install the library via NuGet:
dotnet add package SQLParser
Usage
To use this library in your C# project, follow these steps:
Add a reference to the
SQLParser
package in your project.Import the
SQLParser
namespace in your code:using SQLParser.Parsers.TSql; using SQLParser;
Create a parser listener class:
/// <summary> /// This is an example of a printer that can be used to parse a statement. /// </summary> /// <seealso cref="TSqlParserBaseListener" /> internal class Printer : TSqlParserBaseListener { /// <summary> /// Gets or sets a value indicating whether [statement found]. /// </summary> /// <value> /// <c>true</c> if [statement found]; otherwise, <c>false</c>. /// </value> public bool StatementFound { get; set; } /// <summary> /// Enter a parse tree produced by <see cref="M:SQLParser.Parsers.TSql.TSqlParser.dml_clause" />. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public override void EnterDml_clause([NotNull] TSqlParser.Dml_clauseContext context) { // This is a select statement if the select_statement_standalone is not null StatementFound |= context.select_statement_standalone() != null; base.EnterDml_clause(context); } }
Parse the query:
Parser.Parse("SELECT * FROM Somewhere", ExamplePrinter, Enums.SQLType.TSql);
Contributing
Contributions are welcome! If you encounter any bugs, issues, or have feature requests, please create an issue on this repository.
If you want to contribute to the codebase, follow these steps:
- Fork the repository.
- Create a new branch for your feature/bug fix.
- Make your changes and write tests if applicable.
- Submit a pull request.
Please ensure that your code follows the existing code style and passes the tests before submitting a pull request.
License
This library is released under the Apache 2 License.
Acknowledgments
- This library was built using ANTLR (version 4).
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 is compatible. 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. |
-
net6.0
- Antlr4.Runtime.Standard (>= 4.13.1)
-
net8.0
- Antlr4.Runtime.Standard (>= 4.13.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SQLParser:
Package | Downloads |
---|---|
SQLHelper.DB
SQLHelper is a simple class to help with databases. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.21 | 43 | 11/4/2024 |
3.0.20 | 270 | 10/29/2024 |
3.0.19 | 6,356 | 6/17/2024 |
3.0.18 | 8,642 | 5/6/2024 |
3.0.17 | 1,009 | 4/30/2024 |
3.0.16 | 212 | 4/29/2024 |
3.0.15 | 2,638 | 3/9/2024 |
3.0.14 | 347 | 3/4/2024 |
3.0.13 | 15,053 | 11/15/2023 |
3.0.12 | 614 | 11/6/2023 |
3.0.11 | 635 | 10/30/2023 |
3.0.10 | 2,517 | 9/18/2023 |
3.0.9 | 603 | 9/11/2023 |
3.0.8 | 754 | 9/4/2023 |
3.0.7 | 633 | 8/29/2023 |
3.0.6 | 267 | 8/28/2023 |
3.0.5 | 1,739 | 8/4/2023 |
3.0.4 | 1,884 | 7/10/2023 |
3.0.3 | 6,205 | 6/10/2022 |
3.0.1 | 16,867 | 4/20/2022 |
3.0.0 | 2,042 | 4/20/2022 |
2.0.15 | 3,422 | 1/11/2022 |
2.0.14 | 7,200 | 2/24/2021 |
2.0.13 | 1,998 | 1/6/2021 |
2.0.11 | 6,698 | 9/13/2020 |
2.0.10 | 20,890 | 3/25/2020 |
2.0.9 | 16,692 | 12/23/2019 |
2.0.7 | 9,943 | 2/21/2019 |
2.0.6 | 2,421 | 8/1/2018 |
2.0.5 | 5,459 | 7/17/2018 |
2.0.4 | 1,508 | 7/3/2018 |
2.0.3 | 917 | 7/3/2018 |
2.0.2 | 3,721 | 5/22/2018 |
2.0.1 | 1,998 | 5/11/2018 |
2.0.0 | 6,902 | 1/2/2018 |
1.0.3 | 14,352 | 9/19/2017 |
1.0.2 | 2,422 | 9/15/2017 |