Project Overview: python – flask – ORDS – Autonomous Database


For the past week and a half I’ve been immersed in learning how python and flask interact with each other so a developer can create a quick/crude web application. I’ve also spent time becoming more familiar with virtual environments (as they pertain to python + flask), jinja, and WTForms (I’m sure I’m forgetting other stuff too). But if you are like me (circa two weeks ago), then most of what I just wrote means nothing. But that’s okay, you have to start somewhere.

I’m trying to learn all I can because I want to share my ideas (and code) with the Oracle community in the hopes that it will lead to more creative and innovative ways to connect with our Autonomous Databases.

If you recall, as of this writing, I currently have my Autonomous Database (ADB) set up; and my three tables are REST enabled (with the help of ORDS). I also have a newly created “appdev” user (for accessing the database remotely).

And what I’m attempting to do is develop a very basic web/mobile-friendly application in python. An application that will transform the JSON (provided via ORDS) coming from the ADB, into a readable and helpful tool.

Which prompts the first question: how do I intend to do this?

I think the best way to tell the story is by starting at the end, briefly, then going back to the beginning, and then periodically returning to the end, maybe giving different characters’ perspectives throughout. Just to give it a bit of dynamism, otherwise, it’s just sort of a linear story.

David Ershon (as portrayed by the legendary Steve Coogan in the critically acclaimed 2010 film The Other Guys

First off, its ridiculously easy to REST enable tables in your ADB. Simple mouse clicks really, take a look:

Now that I’ve REST enabled my tables, I can take the provided URL (see below in the image) and paste it in a separate browser window. Here you see the default is that the first 25 entries in the target table are returned.

JSON output from my Oracle Autonomous Database, courtesy of ORDS.

Of course, with some manipulation I can do much more than what is seen here. But the point is that everything works, thanks to ORDS (huge time saver). Although, we still need to clean up the presentation (or what a typical user might expect).

The actual application

So what I’d like to do is take this…word salad, and clean it up a bit; make it more presentable. Up until now I haven’t stumbled across anything that takes our JSON (via ORDS) and presents it in such a way using python + flask. I think it would be really neat, and a good chance for me to contribute something more than just funny memes and GIFs.

If you recall, I have three datasets:

  1. Wake County Restaurants
  2. Restaurant Health Code Inspections
  3. Restaurant Inspection Violations

All of which share the same primary key (a restaurant ID). So I thought I would produce something that would use all three of these tables in some combination.

SHOUT OUT: Thanks to Wake County, NC for providing people with these openly-available datasets.

The direction I’m headed is to develop a Minimum Viable Product (MVP), share the code via GitHub, then move onto the next ORDS-inspired project! After spending a few days researching and learning, I’ve cobbled together what I think might work:

A simple mock-up of what this python, flask, autonomous database app might look like.
A simple mock-up of what this python, flask, autonomous database + ORDS app might look like.

This needs explanation. Let me discuss what is going on here.

  1. A user would begin on the landing page (name yet to be determined). This page of course is displayed in html.
  2. Next a user would enter in a restaurant of interest (I’ll have to begin with Wake County, NC as that is all I have access to at the moment). From there the python application would use ORDS to request information from my autonomous database.
  3. Skipping several steps for brevity, eventually this information would then be transmitted back to the user (in html).
NOTE: I intend to follow-up with subsequent posts detailing my development progress. So this should become less opaque as we near the finish line! 

More explanation

Right, so what are flask, jinja, and WTForms?

  • As I understand it, Flask is a web framework that allows python developers to more easily create web applications.
  • Jinja. Apparently writing html is annoying, so jinja is an “engine” that allows developers to write in python-like code and have that code “transformed” into html. Seems like it makes it that much easier to stay in your native language (python in this case).
  • WTForms is used for form “input handling and validation”. My interpretation of this is that python developers aren’t expected to know how to communicate with databases. Much like they wouldn’t be expected to be fluent in html. So it is a way of extended python to handle requests to the ADB.

Learning resources

No single person is an island. Having said that, what follows (in no specific order) are resources that have helped me get to this level of understanding/comprehension. Maybe they’ll help you too.

I’m more of a visual and practical learner, so I’ve primarily been working through tutorials on YouTube and LinkedIn Learning. I found a course on LinkedIn Learning; one that I actually did.

Meanwhile on YouTube, I did a lot of pausing/reviewing/rewinding so I could figure out how everything works together. Luckily, python and flask seem to be very formulaic; not too dissimilar to COBOL.

LinkedIn Learning

Full Stack Web Development with Flask (LinkedIn Learning)

Note: I did sections 1-4. When I got to section 5, I passively followed along for about ¾ of the section, but then reached diminishing returns. I skipped section 6; twas irrelevant.  


The two channels I found helpful:

  • (channel) – you’ll want to use the keywords “flask Fridays”; they go as far back as 2021 and are still on-going
  • Corey Schafer (playlist) – a great start-to-finish series for building a flask/python-based web application (although not Autonomous Database + ORDS specific)

Mac set-up

Bookmark this guide if you want to set up your Mac for anything development-related. In my case the following sections were extremely important for this project:

  • xCode (for some reason doesn’t come preinstalled on Mac)
  • Homebrew
  • Visual Studio Code
  • Python, along with:
    • Pip
    • Virtualenv (where I learned more about virtual environments)

Up next

Next up, I’ll be taking what I’ve learned so far and applying it to this project. Since a user wouldn’t log in, update, or modify anything in this application, the complexity should be low.

That isn’t to say it won’t have its challenges. But in a couple weeks I hope to have the front end connected (via ORDS) to the ADB. I’ve got a good start on what the landing page might look like. And of course once it is all polished up and properly commented, I’ll be sure to share the code.

Screen shot of the landing page for this python, flask, ORDS, Oracle Autonomous Database application
Screen shot of what the landing page currently looks like; running locally in a virtual environment (venv). Next up is to add a search bar and then connect to my Autonomous Database via ORDS.

The dig continues

Time to hit the books.

If you want to learn more about ORDS check out these resources.

And as always, you can find me here:

Leave a Comment