Category: Python

  • List all database files in a SQL Server instance with Python and pyodbc

    For SQL Server management from Linux, I’ve used pymssql on Linux before, but realized lately that it is hard to configure with the heterogeneous environment I am in. So I am giving pyodbc a try. The install on Windows is simple. Listed below is some code that I put together quickly for some testing. It […]

  • Find and replace text in a file with Python

    Continuing my Lego block building, here is the code for myself and whoever will find it useful. Two blocks of code, the first one searches and replaces, then write the results to a new file, leaving the original intact. The second replaces things in place. Highlights: 1. os.path.join is cool, but you’ve got to be […]

  • Building up Python Lego pieces – some directory stuff

    I lost all my Python code that I have written and collected over time, don’t ask why. So I am in the process of building that back up. Here is some code to create directories for a SQL Server gig I am working on. Highlights: 1. Use os.path.join to take care of the forward and […]

  • Having fun with MySQL and Python: converting MySQL character set to utf8

    Lately I worked quite a bit with Python and Linux, writing monitoring and automation utilities. I am in a transition period, so I thought I ought to write some Python stuff interfacing with MySQL for fun, and start positioning myself for expanded career horizon, I hope. To get started, I thought it would be fun […]

  • Remove common lines from files with Python

    I am digging Python. I am writing small pieces of code that does one thing and does it well, kind of like building a solid, reliable Lego piece. When I have a collection of them, I can snap ’em together to make something useful. In fact, I’ve used Python to generate some content behind the […]