First Week: Trials and Tribulations

First week and already I’m working dthrough new challenges. On my first day I was handled a task to dynamically insert information into either a mongodb database or a dynamodb database in a python script. Well, I’ll be the first to admit that I’m not the best with python much less with dynamically selecting a database to input information into. Either way, I looked at it and after some deliberation I decided the best way to do this was to use an IF statement in the code, could be that there is a better method but this worked well enough for me and my coworkers. Code ended up looking something like this

from flask_pymongo import PyMongo

app.config['DATABASE'] = database
app.config['MONGO_DBNAME'] = 'database_name'
app.config['MONGO_URI'] = 'mongodb://localhost:27017/database'

if DATABASE == 'mongodb'
do code

if DATABASE == 'dynamodb'
do code

Ideally this script would run with a flag to specify the database type as well as the name and location of it. In addition to that, I’m working on a report script that pulls information from a dynamodb instance. While working on that I learned that when dealing with a list that’s chock full of maps, it’s best to iterate over the list. I also got my website back up and running which is awesome! I’d like to post a bit more often but if nothing else I’ll be posting roughly once a week. If you have any questions shoot me an email, and I’ll be glad to try to help where I can.