{"id":20962178,"url":"https://github.com/sarvesh30112002/sql-analyzer","last_synced_at":"2025-06-13T06:33:24.865Z","repository":{"id":243007178,"uuid":"811200708","full_name":"Sarvesh30112002/SQL-Analyzer","owner":"Sarvesh30112002","description":"SQL Analyzer is a software that reads SQL queries, performs token analysis, and evaluates the complexity of the queries. The main goals of this project are to categorize and count different types of tokens, analyze query complexity factors such as joins, subqueries, aggregate functions, and conditions, and provide valuable insights into query.","archived":false,"fork":false,"pushed_at":"2024-06-08T08:54:29.000Z","size":193,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T00:53:42.340Z","etag":null,"topics":["java","jdbc","lexical-analyzer","semantic-analysis","sql","sql-analyzer","sql-query-analysis","syntax-analysis"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sarvesh30112002.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-06T06:19:37.000Z","updated_at":"2024-06-08T08:54:33.000Z","dependencies_parsed_at":"2024-06-08T09:40:26.476Z","dependency_job_id":null,"html_url":"https://github.com/Sarvesh30112002/SQL-Analyzer","commit_stats":null,"previous_names":["sarvesh30112002/sql-analyzer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sarvesh30112002%2FSQL-Analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sarvesh30112002%2FSQL-Analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sarvesh30112002%2FSQL-Analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sarvesh30112002%2FSQL-Analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sarvesh30112002","download_url":"https://codeload.github.com/Sarvesh30112002/SQL-Analyzer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243358306,"owners_count":20277995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","jdbc","lexical-analyzer","semantic-analysis","sql","sql-analyzer","sql-query-analysis","syntax-analysis"],"created_at":"2024-11-19T02:23:56.028Z","updated_at":"2025-03-13T07:12:54.202Z","avatar_url":"https://github.com/Sarvesh30112002.png","language":"Java","readme":"# SQL Analyzer\nSQL Analyzer is a software that reads SQL queries, performs token analysis, and evaluates the complexity of the queries. The main goals of this project are to categorize and count different types of tokens, analyze query complexity factors such as joins, subqueries, aggregate functions, and conditions, and provide valuable insights into query. \n\n\n\u003chr\u003e\n\n### Overview \nThe SQL Analyzer project is a Java-based application designed to analyze SQL queries, validate them, optimize their structure, and display various statistics about the query complexity. It includes both a command-line interface and a graphical user interface (GUI) built with Java Swing. This tool is useful for database administrators, developers, and anyone interested in understanding and optimizing their SQL queries.\n\n\u003chr\u003e\n\n### Features\n1. **Query Analysis**:\n   - Tokenizes SQL queries and categorizes tokens as keywords, identifiers, literals, operators, or punctuation.\n   - Counts occurrences of various SQL components like joins, subqueries, aggregate functions, and conditions.\n   - Determines query complexity based on the counts of these components.\n\n2. **Query Validation**:\n   - Validates SQL queries using JDBC.\n   - Provides detailed error messages for invalid queries.\n   - Stores validation results in a MySQL database.\n\n3. **Query Optimization**:\n   - Optimizes SQL queries by replacing \"*\" with specific column names (simple example).\n\n4. **Graphical User Interface**:\n   - User-friendly interface for entering SQL queries.\n   - Displays original and optimized queries, validation results, token analysis, and query complexity.\n   - Shows query results in a tabular format.\n\n\u003chr\u003e\n\n## Requirements\n- Java Development Kit (JDK) 8 or later\n- MySQL Database\n- JDBC Driver for MySQL\n- An IDE or text editor for Java development\n\n\u003chr\u003e\n\n## Classes and Methods\nSQLTokenAnalyzer.java\nMain Class:\npublic static void main(String[] args): Reads queries from input.sql and analyzes them.\nHelper Methods:\npublic static void analyzeQuery(String query): Analyzes the given SQL query and prints token counts and complexity analysis.\npublic static boolean isKeyword(String token): Checks if a token is a SQL keyword.\npublic static boolean isIdentifier(String token): Checks if a token is an identifier.\npublic static boolean isLiteral(String token): Checks if a token is a literal.\npublic static boolean isOperator(String token): Checks if a token is an operator.\npublic static boolean isPunctuation(String token): Checks if a token is punctuation.\npublic static int countOccurrences(String text, String keyword): Counts occurrences of a keyword in the text.\nJDBC.java\nMain Class:\npublic static void main(String[] args): Launches the GUI.\nHelper Methods:\nprivate boolean validateSQLQuery(String sqlQuery): Validates the SQL query and stores results in the database.\nprivate String optimizeSQLQuery(String sqlQuery): Optimizes the SQL query (simple example).\nprivate void analyzeTokens(String sqlQuery): Analyzes tokens in the SQL query and displays them in the GUI.\nprivate String executeQuery(String sqlQuery): Executes the SQL query and returns the result as a string.\nprivate static int countJoins(String sqlQuery): Counts JOIN clauses in the query.\nprivate static int countSubqueries(String sqlQuery): Counts SELECT clauses in the query.\nprivate static int countAggregateFunctions(String sqlQuery): Counts aggregate functions in the query.\nprivate static int countConditions(String sqlQuery): Counts WHERE clauses in the query.\nprivate void displayQueryResultTable(String queryResult): Displays query result in a table format.\n\n\u003chr\u003e\n\n## Demo\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"Demo/Screenshot (781).png\" alt=\"image\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"Demo/Screenshot 2024-06-06 114003.png\" alt=\"image\"/\u003e\n\u003c/p\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarvesh30112002%2Fsql-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsarvesh30112002%2Fsql-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsarvesh30112002%2Fsql-analyzer/lists"}