Methods
[src]
pub fn get<T>(self, col: int | string): T throws SqlError {
switch (let col = col.(type)) {
case int:
return try (self as _sql.Row).get::<T>(col);
case string:
return try (self as _sql.Row).get_by_name::<T>(col);
}
}
Return the value of a column index or name in this row.
[src]
pub fn get<T>(self, col: int | string): T throws SqlError {
switch (let col = col.(type)) {
case int:
return try (self as _sql.Row).get::<T>(col);
case string:
return try (self as _sql.Row).get_by_name::<T>(col);
}
}
Return the value of a column index or name in this row.
Return the value of a column index or name in this row.
The col is union type of int and string, that support use column index or column name to get value.
nv,
use sql.Connection;
let conn = try! Connection.connect("sqlite::memory:");
let row = try! conn.query("SELECT 1, 'hello'").next()!;
assert try! row.get::<int?>(0) == 1;
assert try! row.get::<string?>(1) == "hello";
PostgreSQL
| Column Type | Navi Type | Description |
|---|---|---|
SMALLSERIAL, SERIAL, BIGSERIAL |
int |
|
INTERVAL |
NOT SUPPORT | |
CHARACTER VARYING, VARCHAR |
string |
|
TEXT |
string |
|
VARCHAR[] |
[string] |
|
INT[], BIGINT[] |
[int] |
|
TINYINT, SMALLINT, MEDIUMINT, INTEGER, BIGINT |
int |
|
DECIMAL, NUMERIC |
TODO | |
REAL, DOUBLE |
float |
|
FLOAT[] |
[float] |
|
BIT |
bool |
|
DATE, TIME, TIMESTAMP, TIMESTAMPTZ |
string |
|
JSON |
NOT SUPPORT | |
ENUM |
string |
MySQL
| Column Type | Navi Type | Description |
|---|---|---|
CHAR, VARCHAR |
string |
|
TEXT |
string |
|
BINARY, VARBINARY |
NOT SUPPORT | |
ENUM |
string |
|
INTEGER, TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT, INT2, INT8 |
int |
|
DECIMAL |
TODO | |
FLOAT, DOUBLE |
float |
|
SET |
string |
|
BLOB |
NOT SUPPORT | |
BIT |
bool |
|
DATE, DATETIME, TIMESTAMP, TIME, TIMESTAMPTZ |
string |
|
JSON |
NOT SUPPORT |
SQLite
| Column Type | Navi Type | Description |
|---|---|---|
INT, INTEGER, TINYINT, SMALLINT, MEDIUMINT, BIGINT |
int |
|
UNSIGNED BIG INT, INT2, INT8 |
int |
|
CHARACTER(20), VARCHAR(255), VARYING CHARACTER(255), TEXT, CLOB |
string |
|
NCHAR(55), NATIVE CHARACTER(70), NVARCHAR(100) |
string |
|
REAL, DOUBLE, DOUBLE PRECISION, FLOAT |
float |
|
BOOLEAN |
bool |
|
BLOB |
NOT SUPPORT | |
DATE, DATETIME, TIMESTAMP |
string |
|
DECIMAL |
TODO |
[src]
pub fn len(self): int {
return (self as _sql.Row).len();
}
Return number of columns in this row.
[src]
pub fn len(self): int {
return (self as _sql.Row).len();
}
Return number of columns in this row.
Return number of columns in this row.
[src]
pub fn scan<T>(self): T throws SqlError {
return try (self as _sql.Row).scan::<T>();
}
Scan the values of this row into the given variables.
[src]
pub fn scan<T>(self): T throws SqlError {
return try (self as _sql.Row).scan::<T>();
}
Scan the values of this row into the given variables.
Scan the values of this row into the given variables.
See also: get method for more details about the supported types and how they are mapped.
nv,
use sql.Connection;
struct User {
name: string,
city: string,
#[serde(rename = "id")]
stuff_no: int,
}
let conn = try! Connection.connect("sqlite::memory:");
let row = try! conn.query_one("SELECT * FROM users LIMIT 1")!;
let user = try! row.scan::<User>();
assert_eq user.name, "Jason Lee";
assert_eq user.city, "Chengdu";
assert_eq user.stuff_no, 1001;