Adds python file to setup database #6

Merged
w25tran merged 2 commits from william/setup-db into main 2 years ago
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

Also adds the DB file to gitignore

Also adds the DB file to gitignore
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

setup_db.py won't run properly if the table already exists.
Should I account for that possibility?

setup_db.py won't run properly if the table already exists. Should I account for that possibility?
a3thakra commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

What's active?

What's `active`?
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

changed this line in version 3 of the diff

changed this line in [version 3 of the diff](/csc/linktree/-/merge_requests/1/diffs?diff_id=50364&start_sha=2e1344d49a526d48be92f702e9ee373299b652de#734d5c2105dc10f04e99fe6dbf6504fa9a4fd99c_15_15)
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

added 1 commit

  • b4a99602 - Add position column to links table

Compare with previous version

added 1 commit <ul><li>b4a99602 - Add position column to links table</li></ul> [Compare with previous version](/csc/linktree/-/merge_requests/1/diffs?diff_id=50364&start_sha=2e1344d49a526d48be92f702e9ee373299b652de)
a3thakra commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

position should also have a unique constraint: More info here: https://www.w3schools.com/sqL/sql_unique.asp

`position` should also have a unique constraint: More info here: https://www.w3schools.com/sqL/sql_unique.asp
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

changed this line in version 4 of the diff

changed this line in [version 4 of the diff](/csc/linktree/-/merge_requests/1/diffs?diff_id=50515&start_sha=b4a996023a6c965b61d52374906d1e64b9120dbf#734d5c2105dc10f04e99fe6dbf6504fa9a4fd99c_15_15)
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

added 2 commits

  • 28f1c680 - Add constraints to links table columns
  • 98dacb78 - Add check to see if links table already exists

Compare with previous version

added 2 commits <ul><li>28f1c680 - Add constraints to links table columns</li><li>98dacb78 - Add check to see if links table already exists</li></ul> [Compare with previous version](/csc/linktree/-/merge_requests/1/diffs?diff_id=50515&start_sha=b4a996023a6c965b61d52374906d1e64b9120dbf)
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

active represents a bool value for whether we want the link to show

`active` represents a bool value for whether we want the link to show
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

resolved all threads

resolved all threads
a3thakra commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

Is there a need to have a separate active column? If it's in the database, it should implicitly be shown. We can just remove it from the database if we want to hide it.

On the other hand, it does provide us functionality to just hide certain links. What do you think @n3parikh?

Is there a need to have a separate `active` column? If it's in the database, it should implicitly be shown. We can just remove it from the database if we want to hide it. On the other hand, it does provide us functionality to just hide certain links. What do you think @n3parikh?
a3thakra commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner
import os

DB_PATH = os.path.join(os.path.dirname(__file__), 'links.db')

con = sqlite3.connect(DB_PATH)

If I call the script from the repo's root directory, links.db is created in the repo's root directory (i.e. near the frontend and backend folders). But if I call it from the backend folder, it creates a links.db in the backend folder (i.e. /backend/links.db)

The suggestion above makes sure that links.db is always created inside the backend folder.

```suggestion:-0+0 import os DB_PATH = os.path.join(os.path.dirname(__file__), 'links.db') con = sqlite3.connect(DB_PATH) ``` If I call the script from the repo's root directory, `links.db` is created in the repo's root directory (i.e. near the frontend and backend folders). But if I call it from the backend folder, it creates a `links.db` in the backend folder (i.e. /backend/links.db) The suggestion above makes sure that links.db is always created inside the backend folder.
a3thakra commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

Good job! 💯

Good job! :100:
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

changed this line in version 5 of the diff

changed this line in [version 5 of the diff](/csc/linktree/-/merge_requests/1/diffs?diff_id=50546&start_sha=98dacb78a3beafaa854f573b70681a988490fc4e#734d5c2105dc10f04e99fe6dbf6504fa9a4fd99c_2_2)
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

added 1 commit

  • 676442ac - Apply 1 suggestion(s) to 1 file(s)

Compare with previous version

added 1 commit <ul><li>676442ac - Apply 1 suggestion(s) to 1 file(s)</li></ul> [Compare with previous version](/csc/linktree/-/merge_requests/1/diffs?diff_id=50546&start_sha=98dacb78a3beafaa854f573b70681a988490fc4e)
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

Would we ever run into a scenario where we want to keep an inactive event in the database in order to be able to access the number of clicks it had?

Would we ever run into a scenario where we want to keep an inactive event in the database in order to be able to access the number of clicks it had?
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

This is now accounted for.

This is now accounted for.
a3thakra commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

I'm leaning towards removing it for now. If we need the feature later on, we can always add it back.

I'm leaning towards removing it for now. If we need the feature later on, we can always add it back.
n3parikh commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

Can you turn this into exception, just so it's more obvious it's a "failure"?

Can you turn this into exception, just so it's more obvious it's a "failure"?
n3parikh commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

Okay, let's drop the active column for now, and I'll create another task to add it if we decide we need it.

Okay, let's drop the `active` column for now, and I'll create another task to add it if we decide we need it.
n3parikh commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

Looks good overall! Just 2 things to change, and it should be good to merge after.

Looks good overall! Just 2 things to change, and it should be good to merge after.
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

changed this line in version 6 of the diff

changed this line in [version 6 of the diff](/csc/linktree/-/merge_requests/1/diffs?diff_id=50691&start_sha=676442ac07895514ba56d391cead26d0fc20a57e#734d5c2105dc10f04e99fe6dbf6504fa9a4fd99c_23_23)
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

added 3 commits

  • 3035b138 - Remove active column
  • 9e5bb54e - Raise exception if links tables already exists
  • 288de5a4 - Merge remote-tracking branch 'refs/remotes/origin/william/setup-db' into william/setup-db

Compare with previous version

added 3 commits <ul><li>3035b138 - Remove active column</li><li>9e5bb54e - Raise exception if links tables already exists</li><li>288de5a4 - Merge remote-tracking branch &#39;refs/remotes/origin/william/setup-db&#39; into william/setup-db</li></ul> [Compare with previous version](/csc/linktree/-/merge_requests/1/diffs?diff_id=50691&start_sha=676442ac07895514ba56d391cead26d0fc20a57e)
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

resolved all threads

resolved all threads
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

Should be good now.

Should be good now.
w25tran commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

resolved all threads

resolved all threads
n3parikh commented 2 years ago (Migrated from git.uwaterloo.ca)
Owner

added 2 commits

  • 37b59ed4 - 1 commit from branch main
  • 89977d3c - Merge branch 'main' into william/setup-db

Compare with previous version

added 2 commits <ul><li>37b59ed4 - 1 commit from branch <code>main</code></li><li>89977d3c - Merge branch &#39;main&#39; into william/setup-db</li></ul> [Compare with previous version](/csc/linktree/-/merge_requests/1/diffs?diff_id=50707&start_sha=288de5a45bac0ca5dd296b9330a1178ccf49463d)
The pull request has been merged.
Sign in to join this conversation.
No reviewers
No Label deployment
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: old/LinkList#6
Loading…
There is no content yet.