Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/databases/database.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* NaiveSQL implemented in Rust.
* Copyright (C) 2024 Andrew Kushyk
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

use super::tables::table::Table;

struct Database {
tables: Vec<Table>,
}

impl Database {
pub fn new(tables: Vec<Table>) -> Self {
Self {
tables
}
}
}
20 changes: 20 additions & 0 deletions src/databases/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* NaiveSQL implemented in Rust.
* Copyright (C) 2024 Andrew Kushyk
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pub(crate) mod database;
pub(crate) mod tables;
20 changes: 20 additions & 0 deletions src/databases/tables/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* NaiveSQL implemented in Rust.
* Copyright (C) 2024 Andrew Kushyk
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pub(crate) mod table;
pub(crate) mod rows;
19 changes: 19 additions & 0 deletions src/databases/tables/rows/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* NaiveSQL implemented in Rust.
* Copyright (C) 2024 Andrew Kushyk
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pub(crate) mod row;
29 changes: 29 additions & 0 deletions src/databases/tables/rows/row.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* NaiveSQL implemented in Rust.
* Copyright (C) 2024 Andrew Kushyk
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pub struct Row {
columns: Vec<String>,
}

impl Row {
pub fn new(id: u32, columns: Vec<String>) -> Self {
Self {
columns,
}
}
}
34 changes: 34 additions & 0 deletions src/databases/tables/table.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* NaiveSQL implemented in Rust.
* Copyright (C) 2024 Andrew Kushyk
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

use std::collections::HashMap;
use crate::databases::tables::rows::row::Row;

pub struct Table {
name: String,
rows: HashMap<u32, Row>,
}

impl Table {
pub fn new(name: String, rows: HashMap<u32, Row>) -> Self {
Self {
name,
rows,
}
}
}
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* NaiveSQL implemented in Rust.
* Copyright (C) 2024 Andrew Kushyk
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

pub(crate) mod databases;