[][src]Struct questdb::QuestDB

pub struct QuestDB { /* fields omitted */ }

Methods

impl QuestDB[src]

pub fn new(url: &str) -> Self[src]

Creates a new connection to questdb

Example

use questdb::QuestDB;
let connection = QuestDB::new("http://192.168.1.37:9000");

pub async fn exec<'_, '_, T: DeserializeOwned>(
    &'_ self,
    query: &'_ str,
    limit: Option<usize>,
    count: Option<bool>,
    nm: Option<bool>
) -> Result<Vec<T>, Error>
[src]

Compiles and executes the SQL query supplied

Arguments

  • query - query text. It can be multi-line, but query separator, such as ; must not be included.
  • limit - This argument is used for paging. Limit can be either in format of X, Y where X is the lower limit and Y is the upper, or just Y. For example, limit=10,20 will return row numbers 10 thru to 20 inclusive. and limit=20 will return first 20 rows, which is equivalent to limit=0,20
  • count - Instructs /exec to count rows and return this value in message header. Default value is false. There is slight performance hit for requesting row count.
  • nm - Skips metadata section of the response when true. When metadata is known and client is paging this flag should typically be set to true to reduce response size. Default value is false and metadata is included in the response.

Example

use questdb::QuestDB;
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug)]
struct TestData {
    id: i32,
    ts: String,
    temp: f64,
    sensor_id: i32,
}

let connection = QuestDB::new("http://192.168.1.37:9000");
let res = connection.exec::<TestData>("select * from readings", Some(5), None, None)
    .await
    .unwrap();

pub async fn imp<'_>(
    &'_ self,
    file_path: &'static str,
    schema: Option<Vec<SchemaMap>>,
    table_name: &'static str,
    overwrite: Option<bool>,
    durable: Option<bool>,
    atomicity: Option<Atomicity>
) -> Result<(), Error>
[src]

The function imp streams tabular text data directly into a table. It supports CSV, TAB and Pipe (|) delimited inputs and optional headers. There are no restrictions on data size. Data type and structure is detected automatically and usually without additional configuration. However in some cases additional configuration can be provided to augment automatic detection results.

Arguments

  • file_path - Path to the file that is going to be imported
  • schema - List of columns and their types. This will overwrite the default unless the table is already created.
  • table_name - Name of the table where the data will be saved
  • overwrite - Default value is false. Set it to true to have existing table deleted before appending data.
  • durable - When request is durable QuestDB will flush relevant disk cache before responding. Default value is false
  • atomicity - Available values are strict and relaxed. Default value is relaxed. When atomicity is relaxed data rows that cannot be appended to table are discarded, thus allowing partial uploads. In strict mode upload fails as soon as any data error is encountered and all previously appended rows are rolled back.

Example

let connection = QuestDB::new("http://192.168.1.37:9000");
let schema = new_schema!(("movieId", Schema::String), ("imdbId", Schema::Int));

let res = connection.imp("./test.csv", Some(schema), "nu_table123", None, None, None)
    .await
    .unwrap();

pub async fn exp<'_, '_, '_>(
    &'_ self,
    query: &'_ str,
    limit: Option<usize>,
    output_file: &'_ mut File
) -> Result<(), Error>
[src]

Exports the result of the query to a CSV file

Arguments

  • query - query text. It can be multi-line, but query separator, such as ; must not be included.
  • limit - This argument is used for paging. Limit can be either in format of X, Y where X is the lower limit and Y is the upper, or just Y. For example, limit=10,20 will return row numbers 10 thru to 20 inclusive. and limit=20 will return first 20 rows, which is equivalent to limit=0,20

Example

use questdb::QuestDB;
use std::fs::File;

let connection = QuestDB::new("http://192.168.1.37:9000");

let mut output_file = File::create("output.csv").unwrap();
let res = match connection.exp("select * from nu_table", Some(5), &mut output_file)
    .await
    .unwrap();

Auto Trait Implementations

impl !RefUnwindSafe for QuestDB

impl Send for QuestDB

impl Sync for QuestDB

impl Unpin for QuestDB

impl !UnwindSafe for QuestDB

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.