VaporDB

Struct VaporDB 

Source
pub struct VaporDB {
    pub connection: Connection,
    pub db_path: String,
    pub bookmark_manager: Option<BookmarkManager>,
    pub transaction_manager: TransactionManager,
}
Expand description

A high-level API for interacting with SQLite databases through vapor-cli

This struct provides a simplified interface to vapor-cli’s functionality, making it easy to use as a library in other Rust projects.

Fields§

§connection: Connection§db_path: String§bookmark_manager: Option<BookmarkManager>§transaction_manager: TransactionManager

Implementations§

Source§

impl VaporDB

Source

pub fn open<P: AsRef<Path>>(db_path: P) -> Result<Self>

Create a new VaporDB instance with an existing database

Source

pub fn create<P: AsRef<Path>>(db_path: P) -> Result<Self>

Create a new database and return a VaporDB instance

Source

pub fn execute(&self, sql: &str) -> Result<()>

Execute a SQL query and return the result

Source

pub fn execute_with_options( &self, sql: &str, options: &QueryOptions, ) -> Result<()>

Execute a SQL query with custom options

Source

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

List all tables in the database

Source

pub fn show_table_schema(&self, table_name: &str) -> Result<()>

Show schema for a specific table

Source

pub fn show_all_schemas(&self) -> Result<()>

Show all table schemas

Source

pub fn show_database_info(&self) -> Result<()>

Show database information

Source

pub fn export_to_csv(&self, table_name: &str, file_path: &str) -> Result<()>

Export a table to CSV

Source

pub fn export_query_to_csv(&self, query: &str, file_path: &str) -> Result<()>

Export query results to CSV

Source

pub fn start_repl(&self) -> Result<()>

Start the interactive REPL

Source

pub fn start_shell(&self) -> Result<()>

Start the interactive shell

Source

pub fn populate_with_test_data( &self, config: Option<PopulationConfig>, ) -> Result<()>

Populate database with test data

Source

pub fn begin_transaction(&self) -> Result<()>

Begin a transaction

Source

pub fn commit_transaction(&self) -> Result<()>

Commit the current transaction

Source

pub fn rollback_transaction(&self) -> Result<()>

Rollback the current transaction

Source

pub fn is_transaction_active(&self) -> bool

Check if a transaction is active

Source

pub fn bookmark_manager(&mut self) -> Option<&mut BookmarkManager>

Get access to the bookmark manager

Auto Trait Implementations§

§

impl !Freeze for VaporDB

§

impl !RefUnwindSafe for VaporDB

§

impl Send for VaporDB

§

impl !Sync for VaporDB

§

impl Unpin for VaporDB

§

impl !UnwindSafe for VaporDB

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V