added a users table
This commit is contained in:
parent
c7691adb56
commit
b7e85e8c69
14
src/sql.rs
14
src/sql.rs
@ -8,6 +8,15 @@ fn get_connection() -> rusqlite::Connection {
|
|||||||
pub fn create_database() -> Result<()> {
|
pub fn create_database() -> Result<()> {
|
||||||
let connection = get_connection();
|
let connection = get_connection();
|
||||||
|
|
||||||
|
connection.execute(
|
||||||
|
"CREATE TABLE IF NOT EXISTS users (
|
||||||
|
user_id INTEGER PRIMARY KEY,
|
||||||
|
username UNIQUE TEXT NOT NULL,
|
||||||
|
password TEXT NOT NULL
|
||||||
|
)",
|
||||||
|
()
|
||||||
|
)?;
|
||||||
|
|
||||||
connection.execute(
|
connection.execute(
|
||||||
"CREATE TABLE IF NOT EXISTS tests (
|
"CREATE TABLE IF NOT EXISTS tests (
|
||||||
test_id INTEGER PRIMARY KEY,
|
test_id INTEGER PRIMARY KEY,
|
||||||
@ -18,9 +27,10 @@ pub fn create_database() -> Result<()> {
|
|||||||
quote_id INTEGER,
|
quote_id INTEGER,
|
||||||
wpm INTEGER,
|
wpm INTEGER,
|
||||||
accuracy INTEGER,
|
accuracy INTEGER,
|
||||||
user_id INTEGER
|
user_id INTEGER,
|
||||||
|
FOREIGN KEY(user_id) REFERENCES users(user_id)
|
||||||
)",
|
)",
|
||||||
(), // empty parameters list
|
()
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user