diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-03-24 13:48:52 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-03-24 13:48:52 +0100 |
commit | a48660843cc0191b62865b54f29bd9b230589a5e (patch) | |
tree | 071f520c8ccc6caa0a209a2f812e210668f5d0dd /dbinit | |
parent | edbdc5e5893802e74b7d8043f7e1817f77ac1c3a (diff) |
implement `spUpdateFlags`
Diffstat (limited to 'dbinit')
-rw-r--r-- | dbinit/demo.sql | 1 | ||||
-rw-r--r-- | dbinit/makefile | 3 | ||||
-rw-r--r-- | dbinit/procedures.sql | 12 |
3 files changed, 15 insertions, 1 deletions
diff --git a/dbinit/demo.sql b/dbinit/demo.sql index 2672489..56abc36 100644 --- a/dbinit/demo.sql +++ b/dbinit/demo.sql @@ -20,6 +20,7 @@ insert into `formula1`.`nationality` (`country`) values ("United states of America"), ("Japan"), ("North Korea"), + ("Australiƫ"), ("Gelderland zuid"); insert into `formula1`.`racetype` (`raceType`) values diff --git a/dbinit/makefile b/dbinit/makefile index 9e5d5d4..76f867f 100644 --- a/dbinit/makefile +++ b/dbinit/makefile @@ -33,7 +33,8 @@ data.sql: # grant all database permissions (development only) permissions: - echo "grant all privileges on formula1.* to '$(USER)'@'$(HOST)';" + echo "grant all privileges on formula1.* to '$(USER)'@'$(HOST)';" | sudo $(SQL) + echo "grant file on *.* to '$(USER)'@'$(HOST)';" | sudo $(SQL) # delete generated sql files clean: diff --git a/dbinit/procedures.sql b/dbinit/procedures.sql index e69de29..b6b0042 100644 --- a/dbinit/procedures.sql +++ b/dbinit/procedures.sql @@ -0,0 +1,12 @@ +drop procedure if exists spUpdateFlags; + +delimiter $$ +create procedure spUpdateFlags(imgPath varchar(255)) + begin + update `nationality` as `A` + set `A`.`flag` = ( + select load_file(concat(imgPath, `country`, ".png")) as `flag` + from `nationality` as `B` + where `B`.`ID` = `A`.`ID`); + end$$ +delimiter ; |