Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
Skip db system check when runserver command is executed

Basically, I'm looking for a way to break the norm. I recently realised that if for some reason my db connection fails, my entire app goes bunkers. Never imagined this use case until it happened.

What I want is for my drf endpoints that do not make db calls to work fine while also returning a custom db error for endpoints that connect to a db.

P.S: I know I should be concerned about the maintaining a near 100% uptime for the db server. However, I'm prepping for a scenario where something goes wrong and doesn't kill the entire system.

/r/django
https://redd.it/12xyh0w
Tuesday Daily Thread: Advanced questions

Have some burning questions on advanced Python topics? Use this thread to ask more advanced questions related to Python.

If your question is a beginner question we hold a beginner Daily Thread tomorrow (Wednesday) where you can ask any question! We may remove questions here and ask you to resubmit tomorrow.

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/12y1e49
Is it correct a models.py in each blueprint?

I am working in a project and we were discussing about this, what do you think? Is it possible?

I don’t know if the db is gonna work, we are using Oracle and it was a little bit complicated to reflect the tables 😅

Thank you!

/r/flask
https://redd.it/12y2e1l
Hosting Django project on Azure

Hello everyone,

I'm seeking some advice on hosting my Django-based project on Azure. I've used Docker-compose to build the project, but I'm feeling lost and unsure about which approach to take. Should I set up Kubernetes AKS or Azure Containers Instance? Or should I stick with the Containers Web App, or perhaps not use Docker at all?

Additionally, I'm not sure whether I should use Azure Postgres or a containerized database, which can be a bit of a pain to set up. I'm also curious about which Azure features I should use to ensure that my project runs smoothly on Azure.

My project utilizes multiple containers, including Redis, Celery, Flower, and Traefik. Can anyone offer any tips or guidance?

Thank you. 😊

/r/django
https://redd.it/12yhv5o
I uploaded a Python Machine Learning Project video on Youtube - Predicting Incomes using Sci-kit Learn

Hey everyone, I uploaded a new video on my YouTube channel where I walk through a Python Machine Learning project using sci-kit learn to predict incomes based on individual data. In the video, I provide the data set and walk through each step of the project. Thanks, have a great day!

https://www.youtube.com/watch?v=47EzTeIuHYo

/r/Python
https://redd.it/12yo1kr
Wednesday Daily Thread: Beginner questions

New to Python and have questions? Use this thread to ask anything about Python, there are no bad questions!

This thread may be fairly low volume in replies, if you don't receive a response we recommend looking at r/LearnPython or joining the Python Discord server at https://discord.gg/python where you stand a better chance of receiving a response.

/r/Python
https://redd.it/12z0gle
dictf - An extended Python dict implementation that supports multiple key selection with a pretty syntax.

Hi, everyone! I'm not sure if this is useful to anyone because it's a problem you can easily solve with a dict comprehension, but I love a pretty syntax, so I made this: https://github.com/Eric-Mendes/dictf

It can be especially useful for filtering huge dicts before turning into a DataFrame, with the same pandas syntax.

Already on pypi: https://pypi.org/project/dictf/

It enables you to use dicts as shown below:

dictf example

/r/Python
https://redd.it/12ywtn8
My experience upgrading project from Flask v1 to v2

I've had one pretty big project which still was running Flask v.1. Finally decided it's time for v.2 which is now a couple years since initial release. A lot of dependencies were upgraded. There was a fair bit of syntax that I had to change, most of the changes were related to SQLAlchemy, WTForms, Jinja filters. Some parameters were renamed. Some parameters that were positional are now named. Some standard form validations stopped working. I could not test everything because the app is fairly big, so some errors occurred in production and were promptly fixed. But every day I discover some new issues. Flask console, which was running fine before upgrade, does not work, I still can't fix it. Flask-Migrate is also broken, I can't run any migrations.

More specifically, trying to load Flask console throws these 2 errors:

flask.cli.NoAppException: While importing 'wsgi', an ImportError was raised

ModuleNotFoundError: No module named 'wsgi'

And Flask-Migrate complains about db connection:

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1045, "Access denied for user 'user'@'host' (using password: YES)")

The connection is configured using SQLALCHEMY_DATABASE_URI in config, and works fine when the Flask server is running, but for some reason

/r/flask
https://redd.it/12z9wnn
Do any of you code to de-stress?

I work as a mechanical engr/program manager in the biomedical field, but love to hobby code on the side. I enjoy scraping datasets, from real estate to car auction websites, and running different analyses on it. Simple up front metrics, sorting, and deeper ML stuff with scikit.

I've recently cut down on drinking almost entirely and have found myself gravitating towards my laptop at the end of the day to just toy around with code.

There is something oddly comforting about seeing all the multi colored code in VScode. Something pleasantly pleasing about expanding your knowledge to learn better and simpler ways to code things. And something rewarding about getting results that you'll probably never use again after dedicating hours and sometimes weeks of work.

I hope this feeling doesn't fade.. I used to love photography in HS, but started making money doing it and lost most of my passion for it.

/r/Python
https://redd.it/12z56v6
Help - no such file or directory but was fully functioning earlier

Hey all,

I was using JupyterLite and the notebook was doing everything I needed it to until I started getting "error no such file or directory" later in the day. I hadn't changed anything to the csv file's location and even played around with different names, paths, copy path, ect.

I have used Jupyter Notebooks online in the past and haven't seen anything like this. Currently in the process of downloading it for Windows and am going to see how that goes.

Thanks in advance!

/r/JupyterNotebooks
https://redd.it/12yt8xq