forked from yihong0618/running_page
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
21 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from generator.db import init_db, Activity | ||
from config import SQL_FILE | ||
import sqlalchemy | ||
|
||
|
||
def add_column_elevation_gain(session): | ||
# check if column elevation_gain is already added | ||
# if not add it to the db | ||
try: | ||
session.query(Activity).first() | ||
print("column elevation_gain already added, skipping") | ||
except sqlalchemy.exc.OperationalError: | ||
sql_statement = 'alter TABLE "activities" add column elevation_gain Float after average_heartrate' | ||
session.execute(statement=sql_statement) | ||
print("column elevation_gain added successfully") | ||
|
||
|
||
if __name__ == "__main__": | ||
session = init_db(SQL_FILE) | ||
add_column_elevation_gain(session) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters