I have a little python and java (school) experience under my belt, but nothing professional or complete. I am trying to create a small database using MySQL, which I think I already figured out. I am using Python to build functions that let me edit the database and pull information from it. That too I have already figured out how to do. The last problem is creating something for users to interface with so that they too can edit the database.

The db will be on my own server, I think I can run a full python app from the server. But I was thinking of a web browser interface so users can just go to a web page rather than having to run a .exe or whatever.

From reading, I see suggestions of using Flask. Is that generally correct? I'll have my SQL db, python app(s) going back and forth with each other. And then Flask going back and forth between python and HTML/CSS? Really I just need to have access to html forms that send data to a python function that modifies the db. Or is using just a plain python GUI okay? It would certainly cut down on trying to brush up on my html, css, and javascript.

My brain is just kind of overloaded right now and any help would be appreciated.

  • CoconutOctopus [it/its]
    ·
    3 years ago

    If you've already written your database access layer, then I agree with everyone else that Flask is probably your best choice. If you hadn't, I would have said Django — you could have saved yourself some time on that part, and gotten a lot of built-in functionality. It's better to do a web front-end for what you're doing than a GUI app, for a variety of reasons I can elaborate on but would rather not.

  • SolidaritySplodarity [they/them]
    ·
    3 years ago

    Is this purely for learning or are you trying to build something that you'll put on the web / is meant to be used by others? If the former, your plan is fine. If the latter, I recommend using at least some layer of abstraction between your database and your app that's a proper db library. Depending on how you've coded it, you might not have the security features essential for putting data in an SQL RDBMS via the web - like catching early semicolons on inputs, a common injection attack. If you prefer the flask ecosystem, then SQLAlchemy is probably what you'd want, though eventually you'd develop a sense for whether it's the right abstraction.

    • mr_world [they/them]
      hexagon
      ·
      3 years ago

      Do you have a resource where I can read bout the different layers? Not sure what to call it for googling purposes.

      • SolidaritySplodarity [they/them]
        ·
        3 years ago

        Due to software being infinitely abstractable, there are a ton of different strategies around how to define layers. Web stuff is already complicated enough, so I don't want to to overload you with all the common software design / architecture strategies, ha.

        I think a good starting place for a beginner is to create a simple CRUD app. In a CRUD app with an anemic domain model, stuff that users see in the front end is (relatively) directly retrieved from the database through a "model", usually an ORM like SQLAlchemy or Django's, and entering data from the front end is also pretty directly entered into the models. Any tutorial about Flask + SQLAlchemy or Django will have you define these layers (model, routes, views/templates) following is h CRUD paradigm.

        This is a good place to start because there's plenty of context to learn around it already without talking about the other layers that devs sometimes use. The domain will make a lot more sense once you've picked up the following knowledge and that takes time:

        • Using the command line
        • Using git
        • SQL
        • ORMs
        • HTTP requests/responses
        • defining routes
        • network ports
        • HTML/CSS and at least one templating language, which both Flask and Django have
        • Enough JavaScript to be dangerous
        • OOP and when to use it
        • maybe docker

        It's a lot! But don't get overwhelmed, everybody had to go through this phase where everything is poorly explained and you don't know what to do next. Building a CRUD app and really understanding what every piece is doing will already knock out half of the above.

    • mr_world [they/them]
      hexagon
      ·
      3 years ago

      What would you suggest? I'll have maybe a dozen users at once, max.

      • reddit [any,they/them]
        ·
        3 years ago

        Python will be fine for that, don't optimize earlier than you need to. Is your front end going to be static pages/templates served by Flask? Or are you writing a web app that just talks to your API?

        • mr_world [they/them]
          hexagon
          ·
          3 years ago

          I'm not sure how to classify it tbh. I mainly need to generate reports from the db, display images, and then have a sign-in/sign-out system for items. But I would also like to have different users other than myself be able to edit the db as well. Ideally the pages wouldn't be static in terms of the information they display. If one person changes the db, I want that change to show up without the user manually refreshing.

          • reddit [any,they/them]
            ·
            3 years ago

            Gotcha. Depends how you want to architect it then, which in turn probably depends on what you know. Either way, you'll need some JS on the front end checking for updates, but if you do it right you can wait to add that till later. If you want to get a little fancy, you can do that with websockets, but you could also just poll the server every X seconds and update the data. If you don't want the page to actually refresh out from under the user you'll probably want an actual dynamic web page, but if you don't care about that then you can just do static templates served by flask -> put some js in the templates to poll for updates -> have that js refresh the page when there's an update.

            If you want to get really fancy - I've heard rethinkdb is a really interesting project for refreshing display data based on a db query. But very overkill for something like this.

  • Shrek
    ·
    edit-2
    3 years ago

    deleted by creator

  • steve5487 [none/use name]
    ·
    edit-2
    3 years ago

    I worked on a project that used flask for a web based SQL using html a couple of years ago. As I recall Flask worked well for using the database and was a big help. I'd be willing to help if you want but I warn you the last time I did something like this was a couple years ago so I might not be that much help

    • mr_world [they/them]
      hexagon
      ·
      3 years ago

      Thanks for the offer but this is work-related and there's no sense in anyone but me doing labor on this. My job is a full time job but it's not a full time work, I have some spare time. I'm trying to relearn some programming stuff for my own enrichment and to help out me and my coworkers. A database is sorely needed because we're running purchasing, quality control, and inventory almost completely on spreadsheets. The rest is locked behind some 1995-ass commercial software specific to the industry that costs thousands per month to use. I'm not trying to replace that, just supplement it so we can stop having to do spreadsheets by hand.

      I'm not even getting paid extra to do this, just trying to fill my spare time with a project. I'm doing the capitalist thing of hoping I'll get some "skills" that I can parley into a raise or a better position. Probably won't though. We'll just use it while I'm here, I won't get paid any extra for it, and they'll stop using it when I move on to a different job. In that case at least I will have a deep refresher on programming which I can use on a personal project.

  • The_Walkening [none/use name]
    ·
    3 years ago

    Definitely go with Flask - there's some good tutorials on creating CRUD (create, read, update, delete) apps that can help you with this

    • mr_world [they/them]
      hexagon
      ·
      3 years ago

      I wasn't familiar with CRUD that gives me an angle for research, thank you.

  • reddit [any,they/them]
    ·
    3 years ago

    Flask is fine but I personally would also vouch for FastAPI. There are fewer examples out there and there's a little more declarative stuff than Flask but personally I like being able to just make some model classes and let it figure out parsing