acquire_reader_with_attached

Function acquire_reader_with_attached 

Source
pub async fn acquire_reader_with_attached(
    main_db: &SqliteDatabase,
    specs: Vec<AttachedSpec>,
) -> Result<AttachedReadConnection>
Expand description

Acquire a read connection with attached database(s)

This function:

  1. Acquires a read connection from the main database’s read pool
  2. For each attached spec:
    • Validates the attached mode (read-only connections cannot attach read-write)
    • Executes ATTACH DATABASE statement
  3. Returns an AttachedReadConnection guard that auto-detaches on drop

§Arguments

  • main_db - The main database to acquire a connection from
  • specs - Specifications for databases to attach

§Errors

Returns an error if:

  • The main database is closed
  • Cannot acquire a read connection
  • Attempting to attach read-write to a read connection
  • ATTACH DATABASE fails