Using Python SQLAlchemy session in multithreading
SQLAlchemy DB session is not thread safe. In this post, I will show you 2 ways to use it in a multithreading context.
SQLAlchemy DB session is not thread safe. In this post, I will show you 2 ways to use it in a multithreading context.
When you need to use a complicated, or a non-standard API authentication method, or your dev and prd environments don't use the same API authentication method, it might be better to create a Python requests auth method to reduce your work.
Gitlab ships with its own free CICD which works pretty well. This post will give you an example of the CICD file .gitlab-ci.yml
for a Python project running on Gitlab Windows runner.
If you want to create some tables from a python list, you can use the tabulate
module, it can generate the table easily in text mode and in many formats, than you can past it into markdown, wiki files or add the print version to your python CLI in order to give a beautiful output to the CLI users.
pyVmomi eventManager's QueryEvents() method returns by default only the last 1000 events occurred on the vCenter. I will show you how to use another method CreateCollectorForEvents() to create an EventHistoryCollector object and then we use this object to collect all the events in a given time range by using its method ReadNextEvents().
As a Windows DevOps, I often use Powershell and Python, Powershell is installed by Windows out of box, but this is not for Python. And for my working environment, I don't have the administrator privileges on some servers. I will show you in this post how to rapidly deploy Python on Windows as a standard user by using Powershell with Nuget.
__init__
fileWe're familiar to put a python file inside a folder, and create a __init__.py
file under the same folder, then we can easily import the file by import the folder, as the folder is transformed to a python module. But if we don't have the __init__.py, how can we import it?
One of the fastest way to convert Python json dict list to csv file with only 2 lines of code by pandas.
As an ex-sysadmin, I'm in love with the Readline. In Powershell, we have its variation PSReadline. In Python REPL on Windows OS, I'll show you the PyReadline and the PtPython.