{"id":239,"date":"2021-03-14T20:21:47","date_gmt":"2021-03-14T20:21:47","guid":{"rendered":"https:\/\/andrejacobs.org\/?p=239"},"modified":"2022-04-11T20:24:23","modified_gmt":"2022-04-11T20:24:23","slug":"100-days-of-learning-day-6-lets-build-our-own-lego-database-using-mariadb-in-aws-rds-and-openfaas","status":"publish","type":"post","link":"https:\/\/andrejacobs.org\/100-days-challenge\/100-days-of-learning-day-6-lets-build-our-own-lego-database-using-mariadb-in-aws-rds-and-openfaas\/","title":{"rendered":"100 Days of Learning: Day 6 \u2013 Let’s build our own Lego database using MariaDB in AWS RDS and OpenFaaS"},"content":{"rendered":"\n
Photo by brickset.com<\/a><\/p>\n\n\n\n Here is my Log book<\/a><\/p>\n In Severless for Everyone Else<\/a> Alex shows an example of using a node.js function that uses Postgre<\/a> as a database.<\/p>\n I am going to see if I can setup MariaDB (MySQL) in my free tier of AWS.<\/p>\n For this little project I want to have a Lego set database. I will be using Python for the function coding (most likely I will be using Flask<\/a> and SQLalchemy<\/a>).<\/p>\n This learning \/ development will span over a few days depending on how much free time I get.<\/p>\n I want to be able to:<\/p>\n First hurdle was trying to log in with my non-root admin user and was asked to change the password. The first thing you must do once you create an AWS account is to create a new admin user that is not the root user account. You should practically never use the root user on AWS. The problem for me was that I setup a strict password policy and it was trial and error (and logging in as root user) before I could reset the expired password. P.S. Symbol did not include the character > that was generated by 1Password.<\/p>\n I will be following the official AWS documentation<\/a> and tutorial for RDS<\/a><\/p>\n <\/p>\n <\/p>\n <\/p>\n Incase you did not know, MySQL was acquired by Oracle a good while ago. MariaDB sprung up as a fork from MySQL (we won’t get into the politics here).<\/p>\n The best GUI I have found to use on Mac with MySQL \/ MariaDB is MySQLWorkbench (owned by Oracle).<\/p>\n You can download the installer here<\/a>. Select "No thanks, just start my download."<\/p>\n <\/p>\n <\/p>\n Open a new query in MySQLWorkbench and paste the following.<\/p>\n Execute the query and with a bit of luck the new table has been created.<\/p>\n Let us populate some sample data into the table. Again execute the following queries.<\/p>\n Note: I will later be altering the table to include a BLOB to store a cached version of the product Image (download and store ImageURL)<\/p>\n That is a wrap for tonight.<\/strong> Tomorrow I need to setup my Mac for Python 3 development first and then explore the OpenFaaS Flask template<\/a> and possibly see how to add SQLalchemy<\/a> as a dependency.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":" Photo by brickset.com […]<\/p>\n\n
cron<\/code> (I guess) job to do the above (fetch image).<\/li>\n<\/ul>\n
Setting up a MariaDB database in AWS<\/h2>\n
\n
\n
\n
Installing MySQLWorkbench as GUI<\/h2>\n
\n
\n
\n
Create the database table<\/h2>\n
CREATE TABLE `openfaasdb`.`legosets` (\n `pkID` INT NOT NULL AUTO_INCREMENT,\n `LegoID` INT NOT NULL,\n `Description` VARCHAR(200) NULL,\n `ProductURL` VARCHAR(4096) NULL,\n `ImageURL` VARCHAR(4096) NULL,\n PRIMARY KEY (`pkID`),\n UNIQUE INDEX `LegoID_UNIQUE` (`LegoID` ASC));\n<\/code><\/pre>\n
INSERT INTO `openfaasdb`.`legosets` (`LegoID`, `Description`, `ProductURL`, `ImageURL`) VALUES ('21322', 'Pirates of Barracuda Bay', 'https:\/\/www.lego.com\/en-gb\/product\/pirates-of-barracuda-bay-21322', 'https:\/\/live.staticflickr.com\/65535\/49698377257_be3f773feb_b.jpg');\nINSERT INTO `openfaasdb`.`legosets` (`LegoID`, `Description`, `ProductURL`, `ImageURL`) VALUES ('21325', 'Medieval Blacksmith', 'https:\/\/www.lego.com\/en-gb\/product\/medieval-blacksmith-21325', 'https:\/\/images.brickset.com\/sets\/AdditionalImages\/21325-1\/21325-1_95850.jpg');\n<\/code><\/pre>\n