Adds python file to setup database #6

Merged
w25tran merged 2 commits from william/setup-db into main 2021-03-11 07:20:20 -05:00
w25tran commented 2021-03-07 23:13:39 -05:00 (Migrated from git.uwaterloo.ca)

Also adds the DB file to gitignore

Also adds the DB file to gitignore
w25tran commented 2021-03-08 18:23:54 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-08 21:05:23 -05:00 (Migrated from git.uwaterloo.ca)

What's active?

What's `active`?
w25tran commented 2021-03-08 21:16:38 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-08 21:16:39 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-09 17:59:51 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-09 19:56:53 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-09 19:56:53 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-09 19:57:58 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-09 21:31:07 -05:00 (Migrated from git.uwaterloo.ca)

resolved all threads

resolved all threads
a3thakra commented 2021-03-09 23:41:03 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-10 00:16:12 -05:00 (Migrated from git.uwaterloo.ca)
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 2021-03-10 00:17:55 -05:00 (Migrated from git.uwaterloo.ca)

Good job! 💯

Good job! :100:
w25tran commented 2021-03-10 00:21:51 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-10 00:21:51 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-10 00:36:14 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-10 00:37:08 -05:00 (Migrated from git.uwaterloo.ca)

This is now accounted for.

This is now accounted for.
a3thakra commented 2021-03-10 01:01:18 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-10 21:50:59 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-10 21:51:00 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-10 21:51:40 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-10 22:45:53 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-10 22:45:53 -05:00 (Migrated from git.uwaterloo.ca)

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 2021-03-10 22:47:28 -05:00 (Migrated from git.uwaterloo.ca)

resolved all threads

resolved all threads
w25tran commented 2021-03-10 22:48:38 -05:00 (Migrated from git.uwaterloo.ca)

Should be good now.

Should be good now.
w25tran commented 2021-03-10 22:48:46 -05:00 (Migrated from git.uwaterloo.ca)

resolved all threads

resolved all threads
n3parikh commented 2021-03-11 07:19:53 -05:00 (Migrated from git.uwaterloo.ca)

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)
Sign in to join this conversation.
No reviewers
No Label
deployment
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: old/LinkList#6
No description provided.