Skip to main content

register

Function register 

Source
pub fn register(
    conn: &Connection,
    module_name: &str,
    connection_string: impl Into<String>,
    table: impl Into<String>,
    key_field: impl Into<String>,
    value_field: impl Into<String>,
) -> Result<()>
Expand description

Register the postgresql virtual table with SQLite

This function creates a virtual table module that allows querying PostgreSQL database tables using SQL.

§Arguments

  • conn - SQLite connection
  • module_name - Name for the virtual table (e.g., “pg_data”)
  • connection_string - PostgreSQL connection string
  • table - Table name to query
  • key_field - Column name for keys
  • value_field - Column name for values

§Example

use rusqlite::Connection;
use sqlite_vtable_opendal::backends::postgresql;

let conn = Connection::open_in_memory()?;
postgresql::register(
    &conn,
    "pg_data",
    "postgresql://localhost/mydb",
    "documents",
    "id",
    "content"
)?;

// Now you can query: SELECT * FROM pg_data