Skip to main content

Database

Enum Database 

Source
pub enum Database {
    SQLite(SqliteBackend),
    DuckDB(DuckdbBackend),
}

Variants§

Implementations§

Source§

impl Database

Source

pub fn open(path: &str) -> Result<Self, String>

Source

pub fn path(&self) -> &str

Source

pub fn get_info(&self) -> Result<DbInfo, String>

Source

pub fn list_tables(&self) -> Result<Vec<TableInfo>, String>

Source

pub fn list_views(&self) -> Result<Vec<String>, String>

Source

pub fn list_indexes(&self) -> Result<Vec<IndexInfo>, String>

Source

pub fn get_schema(&self, table: &str) -> Result<Vec<ColumnInfo>, String>

Source

pub fn query_table( &self, table: &str, limit: usize, offset: usize, sort: Option<Sort>, ) -> Result<QueryResult, String>

Source

pub fn run_query(&self, sql: &str) -> Result<QueryResult, String>

Source

pub fn get_row_count(&self, table: &str) -> Result<u64, String>

Source

pub fn export_csv<W: Write>( &self, table: &str, sort: Option<Sort>, writer: &mut W, ) -> Result<(), String>

Writes the whole table, in the order it is being viewed in. The page window is deliberately not applied: exporting the fifty rows that happen to be on screen out of thousands is not what the button appears to do.

Neither this nor the query export touches anything specific to a backend, so both live here rather than being written twice.

Source

pub fn export_query_csv<W: Write>( &self, sql: &str, writer: &mut W, ) -> Result<(), String>

Re-runs the query rather than being handed its rows, so the export is not bounded by whatever the caller happens to be holding.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.