Enable UART2 On BeagleBone Black for RS232 Cape

  1. Use this script to ensure UART2 is enabled in the device tree: https://github.com/victorporof/BeagleBone-SPI-UART
  2. Enable ttyO1 it in the firmware using this guide (makes the device appear): http://www.element14.com/community/blogs/mirandasoft/2013/07/30/beaglebone-black-rapid-activation-of-ttyo1-ttyo2-ttyo4-and-ttyo5
  3. Put a paperclip into the RS232 port like in the picture on this page: http://sensorsblog.com/serial-communications/rs232loopbacktest/
  4. echo hello > /dev/ttyO1
  5. cat /dev/ttyO1

Two Column Match - Flask + HandsOnTable

I’m getting more comfortable with Flask, so I decided to experiment with Google App Engine + Flask + HandsOnTable.

I made a small app that takes the contents of the 2nd column and matches it to the rows of the first column. I’ve found myself doing this a few times by manually creating two python lists and comparing them in IDLE, so it saves me that work.

Here’s the code: https://github.com/pawl/2ColumnMatch

SQLalchemy - Simple Select Query

Updated 2026-09-23: fixed the example and updated it for SQLAlchemy 2.0.

from sqlalchemy import create_engine, MetaData, Table

engine = create_engine('sqlite:///cars.db', echo=False)
metadata = MetaData()

cars = Table('cars', metadata, autoload_with=engine)

with engine.connect() as conn:
    for row in conn.execute(cars.select()):
        print(row)

SHOW COLUMNS or Get Column Names From SQLalchemy SELECT Query

Updated 2026-09-26: updated the example for SQLAlchemy 2.0.

http://stackoverflow.com/questions/8947616/python-sqlalchemy-get-column-names-dynamically

Rob Wouter’s answer really helped me out: result.keys() gives you the column names, and each row’s columns and values are on row._mapping (SQLAlchemy 2.0 moved them off the row itself):

from sqlalchemy import create_engine, text

engine = create_engine("sqlite:///example.db")

with engine.connect() as conn:
    result = conn.execute(text("SELECT * FROM users"))
    print(list(result.keys()))  # ['id', 'name', 'email']

    for row in result:
        for column, value in row._mapping.items():
            print(f"{column}: {value}")