Connecting 2 Apps with 2 DBs, no API. wait, what?

By Elad Silberring

Elevator Pitch

The “DATABASES” settings is of the first code any developer encounters but how powerful is that small setting? well, very! I want to show from example of how we do things in USnews and how over the past 10 years we are shifting from an API so old it was created when google plus was popular.

Description

2 Databases & No API

US news a company with 100’s of millions visits per year was my guinea pig and in return In this talk I want to show from my experience how we can use a simple setting to connect 2 DB’s together and using the ORM to publish articles from a CMS/Admin site to the actual news site. I will review why use API and not have everything in the same project/server as well as what are the pros and cons on bypassing an API.

Very Short Personal Background

My name is Elad Silberring, I was born in Dallas,TX, raised in Israel, raised in the US then raised in Israel again only to come back to the US 3 years ago to work at USnews as a tech lead. I have been developing django since v1.3 (2012 in the south package era where syncdb was the solution to all our problems), mostly use python 2.7 (don’t tell anyone). I love the full operation of a web component (shipping, testing, front-end, back-end). At my free time I play music, have adventures with my kids, go ski and snowboarding, yell at my kids, play xbox, put my kids to sleep and try to find time to learn new tech.

Professional Background

I consider myself a self-taught full stack developer with experience in the UX Design, Cyber and lately the news sector with my current employer being US news. I work with tech such as Django, AWS, react & vue, wordpress, SEO tools and all the software that connects them.

WHAT

As a Tech Lead in U.S. News I have come across an opportunity that impacted the way I use django, as part of a mission to upgrade our framework from 10 year old .NET CMS and seeing how everything modern in the company is written in python we decided to relaunch the CMS as…

…wait for it…

A Django admin site ( you are probably screaming “THAT’S NOT ITS PURPOSE!” ).

Now we have reached a point that 99.9% is completed and have already replaced the old code but we found that publishing to our content site through our API can be really hard to maintain, test and debug especially since it was built a long time ago when back then the solution to everything was SQL queries, in our case it could lead to 50+ lines of queries, as an example this is a sub sub chunk of one of those queries: SELECT dt2.review_id, dt2.viso from ( select dt1.review_id, dt1.viso, max(dt1.approvaldate) as approvaldate from ( select * from car_opinion WHERE viso IN (%s) and approvaldate is not null ) dt1 group by dt1.product_id, dt1.viso) dt2)

Some of these chunks aren’t formatted, they have bad naming conventions and worst of all lack documentation or any DB constraints

My proposal is to talk about the django ORM, why it’s better then raw queries and how to use it to avoid API’s internally.

WHY:

This is a subject that I haven’t bumped into in any of my python/django communities and I think developers are not aware of its huge advantages and might even be scared to use it since they have never heard someone who does.

The talk will focus on saving data between 2 separate django projects and I think bringing an example from my company that has millions of views each month will strengthen the use case for this.

HOW:

I have a 25-40 min talk I want to teach about multi django apps multi DB’s

The talk will consist of:

8 minutes - about me and how I got to this

15 minutes - slides

7 minutes - example

5 minutes - summary and how to make a case to bring it in to your company

~5 minutes - Q&A

WHO:

Who will benefit from this talk:

  • Developers new to the ORM concept - see a fast way to get up and running
  • Lead developers considering an internal API - multi-db is not common when deciding on moving data around, this might introduce a new solution
  • Any media driven company
  • Product managers/people - This talks shows a way to explain data to non-developers inside a company