### Generate Default Adapter Configuration with SearchLight.Generator.FileTemplates Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Generates a YAML configuration string for Genie applications, used by the SearchLight generator for database setup. Specify the database and environment. ```julia config_yaml = SearchLight.Generator.FileTemplates.adapter_default_config( database = "production", env = "production" ) println(config_yaml) # => # env: ENV["GENIE_ENV"] # # production: # adapter: SQLite # database: db/production.sqlite3 ``` -------------------------------- ### SearchLight.connect Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Establishes a connection to a SQLite database. It can connect to a file-backed database using the 'database' or 'host' key in the connection data dictionary, or create an in-memory database if no database path is provided. ```APIDOC ## SearchLight.connect(conn_data::Dict) ### Description Establishes a connection to a SQLite database file specified by `conn_data["database"]` or `conn_data["host"]`. If neither key is present or their value is `nothing`, an in-memory database is created. The connection handle is stored in an internal `CONNECTIONS` stack and returned. ### Method `connect` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **conn_data** (Dict) - Required - A dictionary containing connection details. Expected keys are `"database"` or `"host"` for file-backed databases, or empty for in-memory databases. ### Request Example ```julia import SearchLight, SearchLightSQLite # Connect to a file-backed SQLite database conn = SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) # Connect to an in-memory database (useful for testing) conn = SearchLight.connect(Dict()) # Connect using the "host" key (alternative convention) conn = SearchLight.connect(Dict("host" => "db/production.sqlite3")) ``` ### Response #### Success Response (200) - **conn** (SQLite.DB) - The connection handle to the SQLite database. #### Response Example ```julia # For file-backed database SQLite.DB("db/myapp.sqlite3") # For in-memory database SQLite.DB(":memory:") ``` ``` -------------------------------- ### Connect to SQLite Database Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Establishes a connection to a SQLite database. Supports file-backed databases using the "database" or "host" key, or an in-memory database if no key is provided. ```julia import SearchLight, SearchLightSQLite # Connect to a file-backed SQLite database conn = SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) # => SQLite.DB("db/myapp.sqlite3") # Connect to an in-memory database (useful for testing) conn = SearchLight.connect(Dict()) # => SQLite.DB(":memory:") # Connect using the "host" key (alternative convention) conn = SearchLight.connect(Dict("host" => "db/production.sqlite3")) # => SQLite.DB("db/production.sqlite3") ``` -------------------------------- ### SearchLight.Migration.create_table(f, name, options) Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Executes a CREATE TABLE DDL statement. The column definitions are provided via a function f that returns a Vector{String}. ```APIDOC ## `SearchLight.Migration.create_table(f, name, options)` — Create a Database Table Executes a `CREATE TABLE` DDL statement. The column definitions are provided via a function `f` that returns a `Vector{String}`. ```julia SearchLight.Migration.create_table(:articles) do [ SearchLight.Migration.column_id(), # id INTEGER PRIMARY KEY SearchLight.Migration.column(:title, :string, not_null = true), SearchLight.Migration.column(:content, :text), SearchLight.Migration.column(:published, :boolean, default = false), SearchLight.Migration.column(:created_at, :datetime), ] end # => Executes: CREATE TABLE articles (id INTEGER PRIMARY KEY, title TEXT NOT NULL, content TEXT, published BOOLEAN DEFAULT false, created_at DATETIME) ``` ``` -------------------------------- ### Create Migrations Tracking Table Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Creates the schema_migrations table used by SearchLight to track applied database migrations. The table has a single version VARCHAR(30) PRIMARY KEY column. ```julia SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) SearchLight.Migration.create_migrations_table() # => Executes: CREATE TABLE `schema_migrations` (`version` varchar(30) NOT NULL DEFAULT '', PRIMARY KEY (`version`)) # Logs: "Created table schema_migrations" ``` -------------------------------- ### Create a Database Table Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Executes a CREATE TABLE DDL statement. Column definitions are provided via a function that returns a Vector{String}. ```julia SearchLight.Migration.create_table(:articles) do [ SearchLight.Migration.column_id(), # id INTEGER PRIMARY KEY SearchLight.Migration.column(:title, :string, not_null = true), SearchLight.Migration.column(:content, :text), SearchLight.Migration.column(:published, :boolean, default = false), SearchLight.Migration.column(:created_at, :datetime), ] end # => Executes: CREATE TABLE articles (id INTEGER PRIMARY KEY, title TEXT NOT NULL, content TEXT, published BOOLEAN DEFAULT false, created_at DATETIME) ``` -------------------------------- ### SearchLight.Migration.add_index(table_name, column_name; name, unique) Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Creates a regular or unique index on a table column. ```APIDOC ## `SearchLight.Migration.add_index(table_name, column_name; name, unique)` — Add an Index Creates a regular or unique index on a table column. ```julia SearchLight.Migration.add_index(:articles, :title) # => Executes: CREATE INDEX articles_title ON articles (title) SearchLight.Migration.add_index(:users, :email, unique = true) # => Executes: CREATE UNIQUE INDEX users_email ON users (email) ``` ``` -------------------------------- ### SearchLight.Migration.create_migrations_table(table_name) Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Creates the schema migrations table used by SearchLight to track which database migrations have been applied. The table has a single version VARCHAR(30) PRIMARY KEY column. ```APIDOC ## `SearchLight.Migration.create_migrations_table(table_name)` — Create Migrations Tracking Table Creates the schema migrations table used by SearchLight to track which database migrations have been applied. The table has a single `version` VARCHAR(30) PRIMARY KEY column. ```julia SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) SearchLight.Migration.create_migrations_table() # => Executes: CREATE TABLE `schema_migrations` (`version` varchar(30) NOT NULL DEFAULT '', PRIMARY KEY (`version`)) # Logs: "Created table schema_migrations" ``` ``` -------------------------------- ### SearchLight.connection Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Retrieves the most recently established active database connection from the internal connection stack. Throws an exception if no connection is active. ```APIDOC ## SearchLight.connection() ### Description Returns the most recently established connection from the internal connection stack. Throws `SearchLight.Exceptions.NotConnectedException` if no connection exists. ### Method `connection` ### Parameters None ### Request Example ```julia SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) # Retrieve the active connection conn = SearchLight.connection() ``` ### Response #### Success Response (200) - **conn** (SQLite.DB) - The active database connection handle. #### Response Example ```julia SQLite.DB("db/myapp.sqlite3") ``` #### Error Response - **SearchLight.Exceptions.NotConnectedException** - Thrown if no connection has been established. ``` -------------------------------- ### SearchLight.Generator.FileTemplates.adapter_default_config Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Generate Default Config returns a YAML configuration string for use in Genie applications. This is used by the SearchLight generator to scaffold database configuration files. ```APIDOC ## Generator / Configuration ### `SearchLight.Generator.FileTemplates.adapter_default_config(; database, env)` — Generate Default Config Returns a YAML configuration string for use in Genie applications. This is used by the SearchLight generator to scaffold database configuration files. ### Method ```julia config_yaml = SearchLight.Generator.FileTemplates.adapter_default_config( database = "production", env = "production" ) println(config_yaml) # => # env: ENV["GENIE_ENV"] # # production: # adapter: SQLite # database: db/production.sqlite3 ``` ``` -------------------------------- ### Manage Transactions with SearchLight.Transactions Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Wrap database operations in explicit SQLite transactions for atomicity. Use a try-catch block to ensure rollback on error. ```julia try SearchLight.Transactions.begin_transaction() SearchLight.query("INSERT INTO accounts (user_id, balance) VALUES (1, 1000)") SearchLight.query("INSERT INTO accounts (user_id, balance) VALUES (2, 500)") SearchLight.Transactions.commit_transaction() println("Transaction committed successfully") catch e SearchLight.Transactions.rollback_transaction() @error "Transaction rolled back due to error" exception=e end ``` -------------------------------- ### Drop a Table with SearchLight.Migration.drop_table Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Use this function to remove an existing table from the database. Ensure the table name is provided as a symbol. ```julia SearchLight.Migration.drop_table(:old_logs) # => Executes: DROP TABLE old_logs ``` -------------------------------- ### SearchLight.Migration.add_column(table_name, name, column_type; ...) Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Adds a new column to an existing table via ALTER TABLE ... ADD. ```APIDOC ## `SearchLight.Migration.add_column(table_name, name, column_type; ...)` — Add a Column Adds a new column to an existing table via `ALTER TABLE ... ADD`. ```julia SearchLight.Migration.add_column(:articles, :slug, :string, not_null = false) ``` ``` -------------------------------- ### SearchLight.to_store_sql Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Generates the SQL string for persisting a model instance, creating an INSERT or UPDATE statement based on whether the record is new or existing. It supports conflict strategies and appends a clause to retrieve the last inserted row ID. ```APIDOC ## SearchLight.to_store_sql(m; conflict_strategy) ### Description Generates the SQL string for persisting a model instance. For new (unpersisted) records, produces an `INSERT` statement; for existing records, produces an `UPDATE`. Supports `:error` (default), `:ignore`, and `:update` conflict strategies. Appends a `SELECT CASE WHEN last_insert_rowid()` clause to retrieve the inserted row ID. ### Method `to_store_sql` ### Parameters #### Path Parameters None #### Query Parameters - **conflict_strategy** (Symbol) - Optional - The conflict resolution strategy. Defaults to `:error`. Other options are `:ignore` and `:update`. #### Request Body - **m** (Model) - Required - The model instance to generate SQL for. ### Request Example ```julia using SearchLight # Assuming 'm' is a SearchLight model instance # sql_string = SearchLight.to_store_sql(m) ``` ### Response #### Success Response (200) - **sql_string** (String) - The generated SQL statement for INSERT or UPDATE. #### Response Example (Example depends on the model instance 'm' and its state) ``` -------------------------------- ### SearchLight.count(m::Type, q::SQLQuery) Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Appends a COUNT(*) AS __cid column to the query and returns the integer count of matching rows. ```APIDOC ## `SearchLight.count(m::Type, q::SQLQuery)` — Count Matching Records Appends a `COUNT(*) AS __cid` column to the query and returns the integer count of matching rows. ```julia total = SearchLight.count(Article) # => 42 active = SearchLight.count(Article, SearchLight.SQLQuery( where = [SearchLight.SQLWhereExpression("published = ?", true)] )) # => 17 ``` ``` -------------------------------- ### SearchLight.Migration.column(name, column_type; default, limit, not_null) Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Returns a SQL column definition string for use inside create_table. Maps Julia type symbols to SQLite types via TYPE_MAPPINGS. ```APIDOC ## `SearchLight.Migration.column(name, column_type; default, limit, not_null)` — Define a Column Returns a SQL column definition string for use inside `create_table`. Maps Julia type symbols to SQLite types via `TYPE_MAPPINGS`. ```julia # Simple text column SearchLight.Migration.column(:username, :string, not_null = true) # => "username TEXT NOT NULL " # Integer with default SearchLight.Migration.column(:score, :integer, default = 0) # => "score INTEGER DEFAULT 0 " # Boolean SearchLight.Migration.column(:active, :boolean, default = true, not_null = true) # => "active BOOLEAN DEFAULT true NOT NULL " ``` **Type Mappings (Julia → SQLite):** | Julia Symbol | SQLite Type | |---|---| | `:string`, `:char`, `:text` | `TEXT` | | `:integer`, `:int` | `INTEGER` | | `:float` | `FLOAT` | | `:decimal` | `DECIMAL` | | `:datetime` | `DATETIME` | | `:timestamp` | `INTEGER` | | `:boolean`, `:bool` | `BOOLEAN` | | `:binary` | `BLOB` | ``` -------------------------------- ### SearchLight.query Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Executes a raw SQL string against the active database connection and returns the results as a DataFrames.DataFrame. It handles split queries for INSERT statements that also retrieve the last inserted row ID. ```APIDOC ## SearchLight.query(sql::String, conn::DatabaseHandle) ### Description Executes a raw SQL string against the active database connection and returns results as a `DataFrames.DataFrame`. Internally handles split queries for INSERT statements that also retrieve the last inserted row ID. ### Method `query` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **sql** (String) - Required - The raw SQL query string to execute. - **conn** (DatabaseHandle) - Required - The database connection handle. ### Request Example ```julia SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) # Simple SELECT query df = SearchLight.query("SELECT * FROM users WHERE active = 1") # DDL query SearchLight.query("CREATE TABLE IF NOT EXISTS logs (id INTEGER PRIMARY KEY, message TEXT)") ``` ### Response #### Success Response (200) - **df** (DataFrames.DataFrame) - A DataFrame containing the results of the query. For DDL statements, it might be an empty DataFrame or contain metadata depending on the SQL execution. #### Response Example ```julia # For a SELECT query 3×4 DataFrame Row │ users_id users_name users_email users_active │ Int64 String String Int64 ────┼────────────────────────────────────────────────────────── 1 │ 1 Alice alice@example.com 1 2 │ 2 Bob bob@example.com 1 3 │ 5 Carol carol@example.com 1 ``` ``` -------------------------------- ### Retrieve Active SQLite Connection Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Returns the most recently established connection from the internal connection stack. Throws `SearchLight.Exceptions.NotConnectedException` if no connection exists. ```julia SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) # Retrieve the active connection conn = SearchLight.connection() # => SQLite.DB("db/myapp.sqlite3") # Will throw if no connection has been established: # SearchLight.Exceptions.NotConnectedException ``` -------------------------------- ### SearchLight.Migration.drop_table Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Drops an existing table from the database. ```APIDOC ## `SearchLight.Migration.drop_table(name)` — Drop a Table Drops an existing table from the database. ### Method ```julia SearchLight.Migration.drop_table(:old_logs) # => Executes: DROP TABLE old_logs ``` ``` -------------------------------- ### Define a Column for create_table Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Returns a SQL column definition string for use inside create_table. Maps Julia type symbols to SQLite types. ```julia # Simple text column SearchLight.Migration.column(:username, :string, not_null = true) # => "username TEXT NOT NULL " # Integer with default SearchLight.Migration.column(:score, :integer, default = 0) # => "score INTEGER DEFAULT 0 " # Boolean SearchLight.Migration.column(:active, :boolean, default = true, not_null = true) # => "active BOOLEAN DEFAULT true NOT NULL " ``` -------------------------------- ### SearchLight.Transactions Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Wraps database operations in an explicit SQLite transaction for atomicity. ```APIDOC ## Transaction API ### `SearchLight.Transactions.begin_transaction / commit_transaction / rollback_transaction` Wraps database operations in an explicit SQLite transaction for atomicity. ### Method ```julia try SearchLight.Transactions.begin_transaction() SearchLight.query("INSERT INTO accounts (user_id, balance) VALUES (1, 1000)") SearchLight.query("INSERT INTO accounts (user_id, balance) VALUES (2, 500)") SearchLight.Transactions.commit_transaction() println("Transaction committed successfully") catch e SearchLight.Transactions.rollback_transaction() @error "Transaction rolled back due to error" exception=e end ``` ``` -------------------------------- ### Generate SQL for Storing a Model Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Generates SQL for inserting or updating model records. Supports conflict resolution strategies like 'ignore'. ```julia Base.@kwdef mutable struct Article <: SearchLight.AbstractModel id::SearchLight.DbId = SearchLight.DbId() title::String = "" content::String = "" end SearchLight.table(::Type{Article}) = "articles" article = Article(title = "Hello World", content = "My first post") # Generate INSERT SQL sql = SearchLight.to_store_sql(article) # => "INSERT INTO articles (title, content) VALUES ('Hello World', 'My first post') ; SELECT CASE WHEN last_insert_rowid() = 0 THEN -1 ELSE last_insert_rowid() END AS LAST_INSERT_ID" # INSERT OR IGNORE (skip on conflict) sql_ignore = SearchLight.to_store_sql(article, conflict_strategy = :ignore) # => "INSERT OR IGNORE INTO articles (title, content) VALUES ('Hello World', 'My first post') ..." ``` -------------------------------- ### Execute Raw SQL Query Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Executes a raw SQL string against the active database connection and returns results as a `DataFrames.DataFrame`. Handles split queries for INSERT statements to retrieve the last inserted row ID. ```julia SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) # Simple SELECT query df = SearchLight.query("SELECT * FROM users WHERE active = 1") # => 3×4 DataFrame # Row │ users_id users_name users_email users_active # │ Int64 String String Int64 # ────┼────────────────────────────────────────────────────────── # 1 │ 1 Alice alice@example.com 1 # 2 │ 2 Bob bob@example.com 1 # 3 │ 5 Carol carol@example.com 1 # DDL query SearchLight.query("CREATE TABLE IF NOT EXISTS logs (id INTEGER PRIMARY KEY, message TEXT)") ``` -------------------------------- ### SearchLight.delete(m) Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Generates and executes a DELETE FROM SQL statement for a persisted model instance. Resets the model's primary key to an empty DbId after deletion. Throws NotPersistedException if the model has not been saved. ```APIDOC ## `SearchLight.delete(m)` — Delete a Model Record Generates and executes a `DELETE FROM` SQL statement for a persisted model instance. Resets the model's primary key to an empty `DbId` after deletion. Throws `SearchLight.Exceptions.NotPersistedException` if the model has not been saved. ```julia # Fetch and delete a record article = SearchLight.findone(Article, id = 1) SearchLight.delete(article) # => Executes: DELETE FROM articles WHERE id = '1' # article.id is reset to DbId() ``` ``` -------------------------------- ### Fetch Random Records Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Returns a vector of randomly ordered model instances by appending ORDER BY random() to the query. Defaults to fetching one record if limit is not specified. ```julia # Fetch 1 random article (default) random_article = Base.rand(Article) # => 1-element Vector{Article} # Fetch 5 random articles sample = Base.rand(Article, limit = 5) # => 5-element Vector{Article} ``` -------------------------------- ### Base.rand(m::Type; limit) Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Returns a vector of randomly ordered model instances by appending ORDER BY random() to the query. ```APIDOC ## `Base.rand(m::Type; limit)` — Fetch Random Records Returns a vector of randomly ordered model instances by appending `ORDER BY random()` to the query. ```julia # Fetch 1 random article (default) random_article = Base.rand(Article) # => 1-element Vector{Article} # Fetch 5 random articles sample = Base.rand(Article, limit = 5) # => 5-element Vector{Article} ``` ``` -------------------------------- ### Count Matching Records Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Appends COUNT(*) to the query and returns the integer count of matching rows. Can filter results using a SQLQuery. ```julia total = SearchLight.count(Article) # => 42 active = SearchLight.count(Article, SearchLight.SQLQuery( where = [SearchLight.SQLWhereExpression("published = ?", true)] )) # => 17 ``` -------------------------------- ### Add an Index to a Table Column Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Creates a regular or unique index on a table column. Use `unique = true` for unique indexes. ```julia SearchLight.Migration.add_index(:articles, :title) # => Executes: CREATE INDEX articles_title ON articles (title) SearchLight.Migration.add_index(:users, :email, unique = true) # => Executes: CREATE UNIQUE INDEX users_email ON users (email) ``` -------------------------------- ### Add a Column to an Existing Table Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Adds a new column to an existing table using ALTER TABLE ... ADD. Specify column type and constraints. ```julia SearchLight.Migration.add_column(:articles, :slug, :string, not_null = false) ``` -------------------------------- ### SearchLight.disconnect Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Releases the connection handle. In SQLite.jl, this is primarily a no-op that signals intent, as the underlying library manages its own connection lifecycle. ```APIDOC ## SearchLight.disconnect(conn::DatabaseHandle) ### Description Releases the connection handle by setting it to `nothing`. Since SQLite.jl manages its own connection lifecycle, this is primarily a no-op that signals intent. ### Method `disconnect` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **conn** (DatabaseHandle) - Required - The connection handle to disconnect from. ### Request Example ```julia conn = SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) # Disconnect when done SearchLight.disconnect(conn) ``` ### Response #### Success Response (200) This function does not return a value, it modifies the connection state. #### Response Example (No specific response example as it's a procedural operation) ``` -------------------------------- ### Disconnect from SQLite Database Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Releases the database connection handle. This is primarily a no-op as SQLite.jl manages its own connection lifecycle. ```julia conn = SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) # Disconnect when done SearchLight.disconnect(conn) ``` -------------------------------- ### SearchLight.escape_column_name Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Safely escapes a column or table name using SQLite's native identifier quoting. It supports dot-separated qualified names. ```APIDOC ## SearchLight.escape_column_name(c::String, conn::DatabaseHandle) ### Description Safely escapes a column or table name using SQLite's native identifier quoting. Supports dot-separated qualified names (e.g., `"table.column"`). ### Method `escape_column_name` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **c** (String) - Required - The column or table name to escape. - **conn** (DatabaseHandle) - Required - The database connection handle. ### Request Example ```julia conn = SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) SearchLight.escape_column_name("users", conn) SearchLight.escape_column_name("users.email", conn) ``` ### Response #### Success Response (200) - **escaped_name** (String) - The properly escaped column or table name. #### Response Example ```julia "\"users\"" "\"users\".\"email\"" ``` ``` -------------------------------- ### SearchLight.escape_value Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Escapes a literal value for safe inclusion in SQL strings. Numbers are returned as-is, while strings are single-quoted with internal single quotes doubled. ```APIDOC ## SearchLight.escape_value(v) ### Description Escapes a literal value for safe inclusion in SQL strings. Numbers are returned as-is; strings are single-quoted with internal single quotes doubled. ### Method `escape_value` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **v** (Any) - Required - The value to escape. ### Request Example ```julia SearchLight.escape_value(42) SearchLight.escape_value("O'Brien") SearchLight.escape_value("normal string") ``` ### Response #### Success Response (200) - **escaped_value** (Any) - The SQL-safe representation of the value. #### Response Example ```julia 42 "'O''Brien'" "'normal string'" ``` ``` -------------------------------- ### Delete a Model Record Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Generates and executes a DELETE SQL statement for a persisted model instance. Resets the model's primary key after deletion. Throws an exception if the model has not been saved. ```julia # Fetch and delete a record article = SearchLight.findone(Article, id = 1) SearchLight.delete(article) # => Executes: DELETE FROM articles WHERE id = '1' # article.id is reset to DbId() ``` -------------------------------- ### Escape Column/Table Identifier Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Safely escapes a column or table name using SQLite's native identifier quoting. Supports dot-separated qualified names. ```julia conn = SearchLight.connect(Dict("database" => "db/myapp.sqlite3")) SearchLight.escape_column_name("users", conn) # => "\"users\"" SearchLight.escape_column_name("users.email", conn) # => "\"users\".\"email\"" ``` -------------------------------- ### Escape SQL Value Source: https://context7.com/genieframework/searchlightsqlite.jl/llms.txt Escapes a literal value for safe inclusion in SQL strings. Numbers are returned as-is; strings are single-quoted with internal single quotes doubled. ```julia SearchLight.escape_value(42) # => 42 SearchLight.escape_value("O'Brien") # => "'O''Brien'" SearchLight.escape_value("normal string") # => "'normal string'" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.