[[#api-branch][https://img.shields.io/badge/api-master-yellow.svg]] [[#rust-version-requirements][https://img.shields.io/badge/rustc-1.58+-lightgray.svg]]
A small and space-efficient Database Management System that allows you to allocate the size of individual data types in bits (not bytes).
10011100 01010000 ⎾⎺⎺⎺⎺⎺⏋⎾⎺⎺⎺⎺⎺⎺⏋⎾⎺⎺⎺⎺⎺⎺⎺⎺⎺⎺⏋ ^ ^ ^ d1 d2 d3
[[#usage][Usage]]
Installation This project (along with the documentation) will be moved to [[https://crates.io][crates.io]] at some point in the future. Right now, you can clone this repo with
git clone https://github.com/madhavan-raja/furdb.git
and use the directory as an external crate.
Alternatively, you can directly use this repository as a git dependency by adding the following in your project's =Cargo.toml=:
[dependencies] furdb = { git = "https://github.com/madhavan-raja/furdb" }
Additionally, you will need a conversion server such as [[https://github.com/madhavan-raja/fur-converter][Fur Converter]] for the data conversion. The server should be running at the time of all data operations.
Import the crate using
use furdb::{Converter, FurColumn, FurDB, FurDBInfo, FurDataType, FurTable, FurTableInfo};
** Creating a new database
=FurDB::new()= takes two parameters.
- =dbpath= of type =PathBuf=, which contains the directory to create the database.
- =dbinfo= of type =Option
If the database already exists, the information provided as part of =db_info= is ignored. Otherwise, a new database is created with the information present in that.
let dbpath = PathBuf::from("~/FurDB/SampleDB"); let dbinfo = FurDBInfo::new("Sample Database"); let db = FurDB::new(dbpath, Some(dbinfo))?;
** Creating a new table =db::gettable()= takes two parameters. - =tableid= of type =&str=, which has the ID of the table---or the name of the directory representing the table. - =table_info= of type =FurTableInfo=, which contains the table information.
If the table already exists, the information provided as part of the =table_info= is ingored. Otherwise, a new table is created with the informatino present in that. Tables are always created within the database directory.
let tableid = "SampleTable"; let tableinfo = FurTableInfo::new("Sample Table", None)?; let tb = db.gettable(tableid, Some(table_info))?;
** Creating the columns A column in a Fur Tables consists of: - =id= of type =&str=, which should be the key of the value in the =HashMap= of the data. - =description= of type =&str=. - =size= of type =u128=, which should specify the number of bits that the data should use. - =data_type= of type =FurDataType=, which contains the name and =converter= of the said type.
Create a column with
let samplecolumn = FurColumn::new( "samplecolumn", Some("Sample Column"), 11, integerdatatype, );
** Adding data to the table The data for a row is stored in a =HashMap=, with the key corresponding to the =id= of the column and the =value= corresponding to the data.
Add the data using with
let sampledata = [ HashMap::from([("samplecolumn", "7")]), HashMap::from([("sample_column", "6")]), ];
tb.add(&sample_data)?;
** Getting the data The data is returned in a =HashMap=.
let result = tb.get()?;
for row in result { println!("{:?}", row); }