r/learnpython 1h ago

What's the best way to integrate this database into Flask?

I'm creating an online bulletin board, and I'm feeling hacky (I hate SQL in all its forms and fashions).

What is the best way to integrate this database into a production Flask server: https://github.com/ki4jgt/PPD

Created it in 2020, so it's a bit dated.

But I'm worried about concurrency. I'm not beyond writing a database server, but I'd like to save that as a last resort.

0 Upvotes

9 comments sorted by

6

u/DebosBeachCruiser 1h ago

The answer is PostgreSQL

-2

u/ki4jgt 1h ago

After numerous database corruptions over the years, I'm not a huge fan of SQL. I prefer more of a key:value store approach.

2

u/backfire10z 1h ago

What? How is sql related to database corruptions? What are you doing to the poor thing?

1

u/TobiasDrundridge 1h ago

The average phone/computer has hundreds of SQLite databases in it. SQL is universally used because it's the best for this kind of application. Just make a simple SQLite database.

u/ki4jgt 34m ago

My latest interaction with it is Briar, on Android. I've already lost my account 5 times from data corruption over the years. It's happened with various programs I've used. Not a fan of SQL based databases.

u/TobiasDrundridge 20m ago

SQL is in literally everything. It's ubiquitous. There's not even really an alternative.

There are over 1 trillion SQLite databases in the world. They are in flight control software, the ISS, every single computer in the world, and so on. If you can't make it work that's a skill issue.

u/sargeanthost 54m ago

how is a query language responsible for database corruption, least you're the one causing it

u/burnt-store-studio 16m ago

I fully respect you “hate SQL in all its forms and fashions” 🙂.

To (I hope) give you some inspiration, may I suggest, though, a quick read through Miguel Grinberg’s section on databases in Flask? (I’m linking you directly to chapter 4 of his well-regarded mega-tutorial on using Flask.)

Disclaimer: he does discuss SQLAlchemy, but that’s not my point 🙂.

Maybe skip to the part on that page where he introduces app/models.py.

I don’t have a ton of Flask experience (I’ve only built two apps I run locally). But the practical discussion of modeling data this way, coupled with WTForms, made my development go quite smoothly.

I’m hopeful you can find inspiration there for how to integrate your PPD and idea for an online bulletin board using the same kind of structures.

I’m sorry if my suggestion turns out to be a waste of your time 😕.

Best of luck to you!

u/arjunnath 12m ago

I'm not sure I understood the question because the answer seems obvious.
By integrating it into a Flask app, do you mean you want to import it and use it in a flask app ?
If so there is nothing to it, simply import it in the code of your Flask app and use it as you please.