How many times have you struggled trying to properly format datetimes in Python?

I can say it for you, but I really struggled on this in the past.
That’s right! In the past!!

I’ve discovered a way to format dates in Python using just f-strings. If you are not familiar with f-strings, you should! It’s a awesome way to format strings in Python. It's not only in "prints" as you can use it anywhere strings and variables are involved. To know more:

Let me show you an example:

from datetime import datetimedate = datetime(2022, 5, 27, 11, 44)print(f'Your appointment is schedule to start at {date:%I:%M %p} on {date:%Y-%m-%d}.', 'Be there!', sep='\n')

The results will be like:

Your appointment is schedule to start at 11:44 AM on 2022-05-27.
Be there!

Awesome, right?!



Imagine that you’ve deleted an account via WHM. Now you need to recreate it again. Unfortunately, you got the following error message:

Account Creation Status: failed
A database owner with the name USERNAME already exists

Sometimes it happens because some configuration files were not removed from the account-deletion scripts. But here is the simple solution:

Navigate to /var/cpanel/databases:

cd /var/cpanel/databases

Find all files related to deleted USERNAME. You’ll see something like this:


Delete these files.

Now, remove all entries related to USERNAME in these files:


To do it quicker, you can use a sed onliner:

sed -i '/USERNAME/d' /var/cpanel/databases/users.db
sed -i '/USERNAME/d' /etc/dbowners

After this you’ll be able to successfully recreate your terminated account via WHM.