Saturday, April 26, 2014

Windows update pipelines with PowerShell

Testing a set of Windows updates before pushing them to production is a fairly typical strategy, but WSUS doesn't provide great tools for it out of the box. With a bit of PowerShell you can generate a file containing a list of new updates, approve them for the test environment, and later approve the same set for prod.

Monday, April 7, 2014

Creating PostgreSQL bulk import files with Python

PostgreSQL supports COPY FROM for bulk loading tables from CSV and binary files on the server's filesystem, and the equivalent \copy to load the file through psql. Turn off indexes, constraints, and WAL, and COPY FROM is pretty fast. I don't know if it's the fastest way to bulk load into postgres but it sure is fast enough for me - we loaded 49 million records totalling over a terabyte in about 8 hours. It's reasonably portable across versions, too, especially if you minimize the use of binary import files.

Generating the CSV and binary formats from Python is easy enough. Here are samples for each.