Skip to content

Commit 9c2d5c0

Browse files
committed
initial commit
1 parent 98ba0e7 commit 9c2d5c0

7 files changed

Lines changed: 80 additions & 0 deletions

File tree

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,15 @@ target
1919
# and can be added to the global gitignore or merged into this file. For a more nuclear
2020
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
2121
#.idea/
22+
23+
24+
# Added by cargo
25+
26+
/target
27+
28+
29+
# Added by cargo
30+
#
31+
# already existing elements were commented out
32+
33+
#/target

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "sql_docs"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]

sql_files/with_comments.sql

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- Users table stores user account information
2+
CREATE TABLE users (
3+
-- Primary key
4+
id INTEGER PRIMARY KEY,
5+
-- Username for login
6+
username VARCHAR(255) NOT NULL,
7+
-- Email address
8+
email VARCHAR(255) UNIQUE NOT NULL,
9+
-- When the user registered
10+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
11+
);
12+
13+
-- Posts table stores blog posts
14+
CREATE TABLE posts (
15+
-- Primary key
16+
id INTEGER PRIMARY KEY,
17+
-- Post title
18+
title VARCHAR(255) NOT NULL,
19+
-- Foreign key linking to users
20+
user_id INTEGER NOT NULL,
21+
-- Main body text
22+
body TEXT NOT NULL,
23+
-- When the post was created
24+
published_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
25+
);

sql_files/without_comments.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CREATE TABLE products (
2+
id INTEGER PRIMARY KEY,
3+
name VARCHAR(255) NOT NULL,
4+
price DECIMAL(10,2) NOT NULL,
5+
stock INTEGER NOT NULL
6+
);
7+
8+
CREATE TABLE orders (
9+
id INTEGER PRIMARY KEY,
10+
product_id INTEGER NOT NULL,
11+
quantity INTEGER NOT NULL,
12+
order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
13+
);

src/files.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//! The module for working with and loading the content from `sql` files

src/main.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//! main file. for testing. shouldn't be part of crate
2+
use std::fs;
3+
use std::io;
4+
5+
fn main() -> io::Result<()> {
6+
let path = "/home/alex/Projects/sql_docs/sql_files/";
7+
8+
println!("Contents of directory '{}':", path);
9+
for entry in fs::read_dir(path)? {
10+
let entry = entry?;
11+
let path = entry.path();
12+
println!(" {}", path.display());
13+
}
14+
15+
Ok(())
16+
}

0 commit comments

Comments
 (0)