### Install syntaqlite CLI Source: https://context7.com/lalitmaganti/syntaqlite/llms.txt Install the syntaqlite CLI using pip, Homebrew, Cargo, or a bootstrap script. Verify the installation with `syntaqlite --version`. ```bash pip install syntaqlite ``` ```bash brew install LalitMaganti/tap/syntaqlite ``` ```bash cargo install syntaqlite-cli ``` ```bash curl -sSf https://raw.githubusercontent.com/LalitMaganti/syntaqlite/main/tools/syntaqlite | python3 - install ``` ```bash syntaqlite --version ``` -------------------------------- ### Install syntaqlite CLI Source: https://github.com/lalitmaganti/syntaqlite/blob/main/integrations/claude-code/README.md Install the syntaqlite CLI using various package managers or a download script. Ensure the binary is on your PATH. ```bash # Homebrew brew install LalitMaganti/tap/syntaqlite ``` ```bash # Cargo ``` ```bash cargo install syntaqlite-cli ``` ```bash # pip ``` ```bash pip install syntaqlite ``` ```bash # Download script ``` ```bash curl -fsSL https://syntaqlite.com/install.sh | sh ``` -------------------------------- ### MCP Server Tool Examples Source: https://context7.com/lalitmaganti/syntaqlite/llms.txt Examples of using the format_sql, parse_sql, and validate_sql tools exposed by the MCP server. Input and output formats are shown for each tool. ```bash # The server exposes three tools: # format_sql — format with optional style parameters # Input: {"sql": "select a,b from t where x=1", "line_width": 80, "keyword_case": "upper"} # Output: "SELECT a, b FROM t WHERE x = 1;" # parse_sql — return AST as indented text # Input: {"sql": "SELECT id FROM users"} # Output: "SelectStmt\n flags: (none)\n columns:\n ResultColumnList [1 items]..." # validate_sql — check syntax only, returns JSON # Input: {"sql": "SELEC 1"} # Output: {"valid": false, "errors": "error: syntax error near 'SELEC'\n --> :1:1\n..."} # Input: {"sql": "SELECT 1"} # Output: {"valid": true, "errors": ""} ``` -------------------------------- ### Start Syntaqlite Language Server Source: https://github.com/lalitmaganti/syntaqlite/blob/main/README.md Run the `syntaqlite lsp` command to start the Language Server Protocol server. This enables features like diagnostics, format on save, and completions in compatible editors. ```bash syntaqlite lsp ``` -------------------------------- ### Install syntaqlite Claude Plugin Source: https://github.com/lalitmaganti/syntaqlite/blob/main/integrations/claude-code/README.md Add the lalitmaganti-plugins to your Claude environment and then install the syntaqlite plugin. ```bash claude plugin marketplace add lalitmaganti-plugins ``` ```bash claude plugin install syntaqlite@lalitmaganti-plugins ``` -------------------------------- ### Check CLI Installation Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/getting-started/cli.md Verifies that the CLI has been installed correctly by checking its version. ```bash syntaqlite --version ``` -------------------------------- ### Install Syntaqlite with mise Source: https://github.com/lalitmaganti/syntaqlite/blob/main/README.md Use the `mise` tool to manage Syntaqlite installations. This command ensures you have the correct version available in your environment. ```bash mise use github:LalitMaganti/syntaqlite ``` -------------------------------- ### Verify syntaqlite installation Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/getting-started/other-editors.md Run this command to verify that syntaqlite is installed and functioning correctly by formatting a simple SQL query. ```bash syntaqlite fmt -e "select 1" ``` -------------------------------- ### Install Syntaqlite using pip Source: https://github.com/lalitmaganti/syntaqlite/blob/main/README.md Install Syntaqlite via pip for Python environments. This method bundles the binary and is available on all platforms. ```bash pip install syntaqlite ``` -------------------------------- ### Install VS Code Extension Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/templates/index.html Install the Syntaqlite extension for VS Code from the marketplace for real-time diagnostics, formatting, and completions. ```bash ext install syntaqlite.syntaqlite ``` -------------------------------- ### Perfetto Extension Grammar Example Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/extensions-ai-plan.md Example of a grammar file for the Perfetto dialect, defining tokens and a rule for 'CREATE PERFETTO FUNCTION'. ```lemon %token PERFETTO MACRO INCLUDE MODULE RETURNS FUNCTION DELEGATES. %fallback ID FUNCTION MODULE PERFETTO. cmd(A) ::= CREATE or_replace(R) PERFETTO FUNCTION ID(N) LP ... { ... } cmd(A) ::= INCLUDE PERFETTO MODULE ID(M) DOT ID(N). { ... } ``` -------------------------------- ### Install Syntaqlite with Homebrew Source: https://github.com/lalitmaganti/syntaqlite/blob/main/README.md Install Syntaqlite on macOS using Homebrew. This command adds the Syntaqlite tap and installs the CLI tool. ```bash brew install LalitMaganti/tap/syntaqlite ``` -------------------------------- ### Install Syntaqlite via curl and Python Source: https://github.com/lalitmaganti/syntaqlite/blob/main/README.md Download and run the Syntaqlite binary using a curl command piped to `python3`. This method downloads, caches, and auto-updates the binary, requiring no manual installation. ```bash curl -sSf https://raw.githubusercontent.com/LalitMaganti/syntaqlite/main/tools/syntaqlite | python3 - fmt -e "select 1" ``` -------------------------------- ### Syntaqlite CLI Command Examples Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/guides/project-setup.md Demonstrates how to use Syntaqlite CLI commands, showing how configuration file defaults are used and how CLI flags can override them. ```bash # Uses config defaults syntaqlite analyze "**/*.sql" # Overrides just the version for this run syntaqlite analyze --sqlite-version 3.46.0 "**/*.sql" ``` -------------------------------- ### SQL Formatting Example Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/guides/mcp.md After setting up the MCP server, you can ask your client to format SQL. The client will invoke syntaqlite's 'format_sql' tool. ```sql SELECT id, name FROM users WHERE active = 1; ``` -------------------------------- ### Install CLI using Download Script Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/getting-started/cli.md Downloads the latest release to ~/.local/bin. Works on macOS, Linux, and Windows. Optionally pass a custom directory. ```bash curl -sSf https://raw.githubusercontent.com/LalitMaganti/syntaqlite/main/tools/syntaqlite | python3 - install ``` -------------------------------- ### SQL Formatting Example Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/templates/index.html Demonstrates the configurable formatting of SQL queries, including line width, keyword casing, and indentation. The formatter is deterministic. ```sql select u.id,u.name, p.title from users u join posts p on u.id =p.user_id where u.active =1 and p.published=true order by p.created_at desc limit 10 ``` ```sql SELECT u.id, u.name, p.title FROM users u JOIN posts p ON u.id = p.user_id WHERE u.active = 1 AND p.published = true ORDER BY p.created_at DESC LIMIT 10; ``` -------------------------------- ### Install Syntaqlite with Cargo Source: https://github.com/lalitmaganti/syntaqlite/blob/main/README.md Install the Syntaqlite CLI tool using Cargo, Rust's package manager. This is suitable for developers who have Rust and Cargo set up. ```bash cargo install syntaqlite-cli ``` -------------------------------- ### Example syntaqlite.toml Configuration Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/reference/config-file.md This TOML file demonstrates the structure and options for configuring syntaqlite, including schema mapping, formatting preferences, and check levels. ```toml # Default schema for SQL files that don't match any glob in [schemas]. # Optional. If omitted, unmatched files get no schema. # schema = ["schema.sql"] # SQLite version to emulate (e.g. "3.47.0", "latest"). # sqlite-version = "3.47.0" # SQLite compile-time flags to enable. # sqlite-cflags = ["SQLITE_ENABLE_MATH_FUNCTIONS", "SQLITE_ENABLE_FTS5"] # Schema DDL files for validation and completions. # Each entry maps a glob pattern to schema file(s). [schemas] "src/**/*.sql" = ["schema/main.sql", "schema/views.sql"] "tests/**/*.sql" = ["schema/main.sql", "schema/test_fixtures.sql"] "migrations/*.sql" = [] # no schema validation # Formatting options (all optional, shown with defaults). [format] line-width = 80 indent-width = 2 keyword-case = "upper" # "upper" | "lower" semicolons = true # Per-category check levels (all optional, shown with defaults). [checks] parse-errors = "deny" # "allow" | "warn" | "deny" unknown-table = "warn" unknown-column = "warn" unknown-function = "warn" function-arity = "warn" cte-columns = "deny" # schema = "deny" # shorthand for all 4 schema checks ``` -------------------------------- ### Example SQL schema definition Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/getting-started/other-editors.md Define your SQL tables and columns in this file to enable schema validation within syntaqlite. This example defines a 'users' table. ```sql CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT); ``` -------------------------------- ### Example output for unknown function analysis Source: https://context7.com/lalitmaganti/syntaqlite/llms.txt Example output from `syntaqlite analyze` showing a warning for an unknown function 'ROUDN' with a 'did you mean?' suggestion for 'round'. ```bash # Example output for: syntaqlite analyze --schema schema.sql -e "SELECT ROUDN(score,2) FROM users" # warning: unknown function 'ROUDN' # --> :1:8 # | # 1 | SELECT ROUDN(score, 2) FROM users # | ^~~~~ # = help: did you mean 'round'? ``` -------------------------------- ### Install Claude Code Plugin Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/getting-started/claude-code.md Add the marketplace and install the syntaqlite plugin for Claude Code. This enables enhanced SQL editing features. ```bash claude plugin marketplace add LalitMaganti/claude-code-plugin claude plugin install syntaqlite@lalitmaganti-plugins ``` -------------------------------- ### Use Custom Dialect with CLI Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/guides/custom-dialects.md Example command to format SQL using a custom dialect loaded from a shared library. ```bash syntaqlite fmt \ --dialect ./libperfetto.dylib \ --dialect-name perfetto \ -e "create perfetto macro m() returns int as 42" ``` -------------------------------- ### High-Level API Example Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/distribution-ai-plan.md Shows the re-exported parser/tokenizer API alongside formatting, validation, and completion functions from the high-level library. ```c syntaqlite.h + libsyntaqlite ``` -------------------------------- ### Configuring Dialect with CFlags Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/sqlite-multiversion-ai-plan.md Example of initializing a `SyntaqliteDialectConfig` struct with a specific SQLite version and a combination of OMIT and ENABLE cflags. ```c SyntaqliteDialectConfig config = { .sqlite_version = 3035000, .cflags = SYNQ_SQLITE_OMIT_WINDOWFUNC | SYNQ_SQLITE_OMIT_CTE | SYNQ_SQLITE_ENABLE_ORDERED_SET_AGGREGATES, }; ``` -------------------------------- ### Setting Dialect Configuration (C) Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/sqlite-multiversion-ai-plan.md Example of how to set a specific dialect configuration for a Syntaqlite parser, including SQLite version and CFLAGS. ```c SyntaqliteDialectConfig config = { .sqlite_version = 3035000, .cflags = SYNQ_SQLITE_OMIT_WINDOWFUNC, }; syntaqlite_parser_set_dialect_config(parser, &config); ``` -------------------------------- ### C Core API Example Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/distribution-ai-plan.md Illustrates the low-level C API for parsing and tokenizing SQL, intended for embedders who need a self-contained parser. ```c syntaqlite_parser_new syntaqlite_parse ``` -------------------------------- ### Build Syntaqlite from Source Source: https://github.com/lalitmaganti/syntaqlite/blob/main/README.md Build Syntaqlite from its source code. This process involves installing build dependencies and then compiling the project using Cargo. ```bash tools/install-build-deps ``` ```bash tools/cargo build ``` -------------------------------- ### Analyzer::default Source: https://github.com/lalitmaganti/syntaqlite/blob/main/tests/public-api/syntaqlite.txt Creates a new Analyzer instance with default settings. This is a convenient way to get started without explicit configuration. ```APIDOC ## Analyzer::default ### Description Creates a new Analyzer instance with default settings. This is a convenient way to get started without explicit configuration. ### Method `default() -> Analyzer` ### Returns - `Analyzer`: A new Analyzer instance with default settings. ``` -------------------------------- ### Syntaqlite Usage Example Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/syntaqlite-js/README.md Demonstrates initializing the Syntaqlite engine, loading it, and then using its format, parse (AST JSON), and validate functions. Ensure the engine is loaded before use. ```ts import { Engine } from "syntaqlite"; const engine = new Engine(); await engine.load(); // Format SQL const result = engine.format("select id,name from users where id=1"); console.log(result.sql); // SELECT id, name FROM users WHERE id = 1 // Parse SQL to AST (JSON) const ast = engine.astJson("SELECT 1"); console.log(ast); // Validate SQL const diagnostics = engine.diagnostics("SELECT * FROM missing_table"); console.log(diagnostics.entries); ``` -------------------------------- ### TypeScript Usage for Monaco Editor Diagnostics Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/lsp-plan.md Example TypeScript code demonstrating how to use the Syntaqlite WASM module to get diagnostics and display them in the Monaco editor using model markers. ```typescript const count = engine.diagnostics(model.getValue()); if (count > 0) { const diags = JSON.parse(engine.getResult()); monaco.editor.setModelMarkers(model, 'syntaqlite', diags.map(d => ({ startLineNumber: ..., // convert from byte offset message: d.message, severity: monaco.MarkerSeverity.Error, }))); } ``` -------------------------------- ### Install VS Code Extension Dependencies Source: https://github.com/lalitmaganti/syntaqlite/blob/main/integrations/vscode/README.md Install project dependencies for the VS Code extension. This is a prerequisite for development and building the extension. ```sh cd integrations/vscode npm install npm run compile ``` -------------------------------- ### List downloaded files Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/getting-started/c-parser.md Verify that the syntaqlite_syntax.c and syntaqlite_syntax.h files have been successfully downloaded. ```bash ls # syntaqlite_syntax.c syntaqlite_syntax.h ``` -------------------------------- ### Syntaqlite Class Initialization and Usage Source: https://context7.com/lalitmaganti/syntaqlite/llms.txt Demonstrates how to initialize and use the Syntaqlite class, preferably as a context manager for automatic resource management. ```APIDOC ## Syntaqlite Class Initialization **Description** Instantiate the `Syntaqlite` class to perform SQL operations. It's recommended to use it as a context manager (`with syntaqlite.Syntaqlite() as sq:`) for proper handling of worker subprocesses. Creating one instance and reusing it is more efficient than creating a new one for each operation. **Requirements** - Python 3.10+ **Usage Example** ```python import syntaqlite with syntaqlite.Syntaqlite() as sq: # Perform SQL operations using the 'sq' instance pass ``` ``` -------------------------------- ### Perfetto Extension Node Definition Example Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/extensions-ai-plan.md Example of a node definition file for the Perfetto dialect, defining the structure and formatting for a 'PerfettoFunctionStmt'. ```rust node PerfettoFunctionStmt { func_name: inline TextSpan body: index Stmt is_replace: inline Bool fmt { Text("CREATE") IfSet(is_replace) { Text("OR REPLACE") } Text("PERFETTO FUNCTION") Span(func_name) ... } } ``` -------------------------------- ### Write C program to parse SQL Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/getting-started/c-parser.md Create a C program that includes the syntaqlite header, initializes the parser, feeds it SQL text, and processes each statement. This example shows how to parse a default query or one provided as a command-line argument. ```c #include "syntaqlite_syntax.h" #include #include int main(int argc, char** argv) { const char* sql = "SELECT id, name FROM users WHERE active = 1"; if (argc > 1) { sql = argv[1]; } // Create a parser for the SQLite dialect. SyntaqliteParser* p = syntaqlite_parser_create(NULL); // Feed the source text. syntaqlite_parser_reset(p, sql, strlen(sql)); // Parse each statement (a source string can contain multiple). int stmt = 0; for (;;) { int32_t rc = syntaqlite_parser_next(p); if (rc == SYNTAQLITE_PARSE_DONE) break; stmt++; if (rc == SYNTAQLITE_PARSE_ERROR) { fprintf(stderr, "error in statement %d: %s\n", stmt, syntaqlite_result_error_msg(p)); continue; } // Print the AST. uint32_t root = syntaqlite_result_root(p); char* dump = syntaqlite_dump_node(p, root, 0); printf("--- statement %d ---\n%s\n", stmt, dump); free(dump); } syntaqlite_parser_destroy(p); return 0; } ``` -------------------------------- ### syntaqlite lsp command Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/reference/cli.md Start the language server on stdio. On startup, the server discovers syntaqlite.toml from the current directory and uses it for schema loading and formatting defaults. ```bash syntaqlite lsp [OPTIONS] ``` -------------------------------- ### Initialize and use Syntaqlite Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/reference/python-api.md Instantiate the Syntaqlite class using a context manager for automatic cleanup. This is the entry point for all SQL operations. ```python import syntaqlite with syntaqlite.Syntaqlite() as sq: print(sq.format_sql("select 1")) stmts = sq.parse("select * from users") ``` -------------------------------- ### Create a new Rust project Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/getting-started/rust.md Initialize a new Rust project using Cargo and add the syntaqlite library with necessary features. ```bash cargo new sql-check cd sql-check ``` ```bash cargo add syntaqlite --features fmt,analysis,sqlite ``` -------------------------------- ### CLI Formatting with Config Defaults Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/config-file-ai-plan.md Demonstrates using the 'syntaqlite fmt' command. When no formatting flags are provided, it defaults to settings defined in the 'syntaqlite.toml' configuration file. ```bash syntaqlite fmt query.sql ``` -------------------------------- ### Catalog Construction and Initialization Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/semantic-refactor-ai-plan.md Methods for creating and initializing a Catalog instance. ```APIDOC ## Catalog::new() ### Description Creates an empty catalog. Built-in dialect functions are added internally by the analyzer. ### Method `new` ### Parameters None ### Response Returns a new, empty `Catalog` instance. ``` ```APIDOC ## Catalog::from_ddl(source: &str) ### Description Parses DDL statements from the provided source string and populates the database layer of the catalog. ### Method `from_ddl` ### Parameters - **source** (string slice) - A string containing DDL statements. ### Response Returns a `Catalog` instance initialized with schema from the DDL source. ### Feature Requires the `sqlite` feature to be enabled. ``` ```APIDOC ## Catalog::from_json(s: &str) ### Description Parses a JSON schema description string into the database layer of the catalog. ### Method `from_json` ### Parameters - **s** (string slice) - A JSON string describing the schema. Expected format includes `tables`, `views`, and `functions`. ### Response Returns a `Result` containing either a `Catalog` instance initialized from the JSON or a `String` error message. ### Feature Requires the `json` feature to be enabled. ``` -------------------------------- ### Install Syntaqlite JavaScript / WASM package Source: https://github.com/lalitmaganti/syntaqlite/blob/main/README.md Install the Syntaqlite npm package for use in JavaScript or WebAssembly projects. This provides access to the Syntaqlite API in a web environment. ```bash npm install syntaqlite ``` -------------------------------- ### Start Syntaqlite LSP Server Source: https://context7.com/lalitmaganti/syntaqlite/llms.txt Initiate the Language Server Protocol server for integration with editors. This provides features like diagnostics, formatting, and code completion. ```bash # Start the LSP server (editors invoke this automatically) syntaqlite lsp ``` ```bash # Start with a pinned SQLite version syntaqlite --sqlite-version 3.44.3 lsp ``` ```lua # Neovim (lazy.nvim / nvim-lspconfig) example # In your Neovim config: # require('lspconfig').syntaqlite.setup({ # cmd = { 'syntaqlite', 'lsp' }, # filetypes = { 'sql' }, # root_dir = require('lspconfig').util.root_pattern('syntaqlite.toml', '.git'), # }) ``` -------------------------------- ### Python f-string Example Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/embedded-sql-ai-plan.md Demonstrates a Python f-string containing embedded SQL. The example highlights the SQL content and the interpolation holes that need to be identified by the string extractor. ```python query = f"SELECT * FROM {table} WHERE id = {user_id}" # ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ SQL content ``` -------------------------------- ### Get Headers from Options Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/playground/playwright-report/index.html Extracts headers from the options object, returning them as an object or an iterable. ```javascript function pr({options:l}){const{headers:u}=l;if(u)return Symbol.iterator in u?Object.fromEntries(u):u} ``` -------------------------------- ### Eager Module Dictionary Initialization Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/python-rpc-module-resolver-plan.md Initialize Syntaqlite Schema with a pre-defined dictionary of module paths and their SQL sources. This is suitable when all expected modules can be enumerated upfront. ```python schema = syntaqlite.Schema( tables=[...], modules={"stdlib.foo": "CREATE TABLE t(x)", "stdlib.bar": "..."}, ) result = sq.validate(sql, schema) ``` -------------------------------- ### Blockquotes for Callouts Source: https://github.com/lalitmaganti/syntaqlite/blob/main/AGENTS.md Employ blockquotes starting with '> **Note:**' for callouts and important notes within the documentation. ```markdown > **Note:** ... ``` -------------------------------- ### Render Diagnostics to String Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/semantic-refactor-ai-plan.md Example of capturing rendered diagnostics into a string buffer, useful for testing or logging. ```rust let mut buf = Vec::new(); renderer.render_diagnostics(&diags, &mut buf)?; let s = String::from_utf8(buf).unwrap(); ``` -------------------------------- ### Render Diagnostics to Stderr Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/semantic-refactor-ai-plan.md Example of rendering diagnostics directly to standard error using `DiagnosticRenderer::render_diagnostics`. ```rust renderer.render_diagnostics(&diags, &mut std::io::stderr())?; ``` -------------------------------- ### Configure syntaqlite Schemas and Formatting Source: https://github.com/lalitmaganti/syntaqlite/blob/main/integrations/claude-code/README.md Create a syntaqlite.toml file in your project root to define SQL schemas and formatting options. The LSP server reads this configuration automatically. ```toml [schemas] "src/**/*.sql" = ["schema/main.sql"] [format] line-width = 100 ``` -------------------------------- ### TypeScript Embedded SQL Example Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/guides/embedded-sql.md Syntaqlite supports SQL validation within TypeScript template literals. ```typescript // TypeScript — template literals work too const query = ` SELECT id, name FROM users WHERE role = 'admin' `; ``` -------------------------------- ### Get Structured Analysis Results Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/reference/python-api.md Analyze SQL and retrieve structured results, including diagnostics and statements. ```python schema = syntaqlite.Schema(tables=[syntaqlite.Table("users", ["id", "name"])]) r = sq.analyze("SELECT id FROM users", schema) print(r.diagnostics) ``` -------------------------------- ### Format SQL Files Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/reference/cli.md Use 'syntaqlite fmt' to format SQL files. It reads from stdin if no files are provided. CLI flags override configuration file settings. ```bash syntaqlite fmt [OPTIONS] [FILES...] ``` -------------------------------- ### syntaqlite.SyntaqliteError Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/reference/python-api.md Base class for runtime errors raised by a `Syntaqlite` instance — for example, calls made after `close`. ```APIDOC ## `syntaqlite.SyntaqliteError` Base class for runtime errors raised by a [`Syntaqlite`](#syntaqlite-syntaqlite) instance — for example, calls made after [`close`](#sq-close). Inherits from `RuntimeError`. ``` -------------------------------- ### SQL Query Using Interval Data Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/semantic-roles-plan.md Example of a SQL query attempting to select from `my_interval_data`, which is an interval-kinded relation. ```sql SELECT * FROM my_interval_data ``` -------------------------------- ### Serve Playground Directory Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/playground/README.md Command to serve the web playground directory using a static file server, making it accessible via HTTP. ```bash tools/run-web-playground --port 8080 ``` -------------------------------- ### Configure Syntaqlite Project Source: https://github.com/lalitmaganti/syntaqlite/blob/main/README.md Create a `syntaqlite.toml` file in your project root to define schema mappings and formatting rules. This configuration is automatically detected by the LSP, CLI, and editor integrations. ```toml # Map SQL files to schema DDL files for validation and completions. [schemas] "src/**/*.sql" = ["schema/main.sql", "schema/views.sql"] "tests/**/*.sql" = ["schema/main.sql", "schema/test_fixtures.sql"] "migrations/*.sql" = [] # no schema validation for migrations # Default schema for SQL files that don't match any glob above. # schema = ["schema.sql"] # Formatting options (all optional, shown with defaults). [format] line-width = 80 indent-width = 2 keyword-case = "upper" # "upper" | "lower" semicolons = true ``` -------------------------------- ### SQL Syntax Error Example Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/getting-started/vscode.md Demonstrates a syntax error in a SQL query that will be flagged by the VS Code extension. ```sql select id,name,email,created_at from users as u wehre active=1 and role='admin' order by created_at desc ``` -------------------------------- ### Discover Configuration File (Rust) Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/config-file-ai-plan.md Implements the logic to search for `syntaqlite.toml` by walking up the directory tree from a starting path. Returns the parsed configuration and the directory containing the file if found. ```rust pub fn discover(start: &Path) -> Option<(ProjectConfig, PathBuf)> { let mut dir = start; loop { let candidate = dir.join("syntaqlite.toml"); if candidate.is_file() { let contents = std::fs::read_to_string(&candidate).ok()?; let config: ProjectConfig = toml::from_str(&contents).ok()?; return Some((config, dir.to_path_buf())); } dir = dir.parent()?; } } ``` -------------------------------- ### Get Lower 8 Bits Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/playground/playwright-report/index.html Extracts the lower 8 bits of an integer. A utility function for bit manipulation. ```javascript function lh(l){return l&255} ``` -------------------------------- ### Compile and link with shared library (Linux x64) Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/docs/content/guides/c-api.md Compile your C program and link it against the syntaqlite shared library on Linux x64. Ensure the include and library paths are correctly specified. ```bash cc -o my_program my_program.c -I. -Llinux-x64 -lsyntaqlite -Wl,-rpath,'$ORIGIN/linux-x64' ``` -------------------------------- ### SQLite vs. Perfetto CREATE TABLE Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/semantic-roles-plan.md Contrasts the SQL syntax for creating tables in SQLite and Perfetto, highlighting differences in column definition. ```sql -- SQLite CREATE TABLE foo AS SELECT 1 ``` ```sql -- Perfetto CREATE PERFETTO TABLE foo(x INT, y LONG) AS SELECT 1 AS x, 2 AS y ``` -------------------------------- ### Perfetto dialect SQL statement Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/wasm-site-journal.md Example SQL statement for creating a Perfetto table, demonstrating the Perfetto dialect functionality. ```sql CREATE PERFETTO TABLE foo AS select a, b from t where c = 1 ``` -------------------------------- ### Compiling a C Dialect with Syntaqlite Source: https://github.com/lalitmaganti/syntaqlite/blob/main/docs/distribution-ai-plan.md Demonstrates the compilation command for C-only dialect users, combining the Syntaqlite parser, custom dialect code, and application code. This is for integrating custom SQL dialects. ```bash gcc syntaqlite_parser.c syntaqlite_mydialect.c myapp.c -o myapp ``` -------------------------------- ### Get Default Content Type Source: https://github.com/lalitmaganti/syntaqlite/blob/main/web/playground/playwright-report/index.html Returns the default content type, which is 'application/octet-stream'. This is used when no specific content type is provided. ```javascript function j8(){ return"application/octet-stream" } ``` -------------------------------- ### Tabs for Alternative Approaches Source: https://github.com/lalitmaganti/syntaqlite/blob/main/AGENTS.md Use the 'tabs' div with a 'data-tab-group' attribute to implement tabbed content for alternative installation methods or approaches. ```html
```