"logging setup": { | |
"prefix": "logsetup", | |
"body": [ | |
"import logging", | |
"from rich.logging import RichHandler", | |
"", | |
"def setup_logging(verbosity: int = 0, force: bool = False) -> None:", | |
"\t\"\"\"", | |
"\tSet up a root logger with console output.", | |
"", |
""" | |
Compare two Excel sheets | |
Inspired by https://pbpython.com/excel-diff-pandas-update.html | |
For the documentation, download this file and type: | |
python compare.py --help | |
""" | |
import argparse | |
import pandas as pd |
Common Table Expressions (CTEs) are a bit complex and difficult to understand at first blush. Many of the tutorials and examples on the net don't make it any easier for those just starting out. I thought I'd put together a quick gist that tries to simplify the concept and demonstrate how to do recursive queries using CTEs.
Keep in mind that CTEs have other uses besides just recursive queries but this gist is just about how they can be used to create recursive searches.
I'm using SQLite in this example but any SQL language that implements the WITH keyword should be able to do the same thing. If you've never used SQLite before, you are missing out on an amazing, open source, stand alone, SQL engine. I encourage you to check it out.
""" | |
Python script to interact with existing Windows Task Scheduler tasks. | |
CLI usage: | |
python windows_task_scheduler.py {enable|disable|run} -t "TaskName" | |
import usage: | |
import windows_task_scheduler as wts | |
wts.enable_task(task_name='TaskName') | |
wts.disable_task(task_name='TaskName') |
Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.
The basic idea is that C:\Program Files\Git\mingw64\
is your /
directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git
, the mingw64
in this directory is your root. Find it by using pwd -W
).
If you go to that directory, you will find the typical linux root folder structure (bin
, etc
, lib
and so on).
If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so
import cx_Oracle | |
conn = cx_Oracle.Connection("userid/password@tns") | |
curs = conn.cursor() | |
curs.callproc("dbms_output.enable") | |
sqlCode = """ | |
some long | |
sql code | |
with dbms_output |