Skip to content

Comment on Show HN: PugSQL, a Python Port of HugSQLparent

Comments

Looks like sqlalchemy is just used for the "being able to handle multiple databases" part, not for its higher level abstractions.

You may of course already be aware of this but it's worth pointing out. To many, SQLAlchemy is an ORM, but the SA developers very purposefully made the ORM layer completely optional. The SQLAlchamy-Core layer can be used to functionally compose queries without mapping types at all, and below that, SA can be used as an abstract but featureful generic client for executing just raw SQL.

Thank you (and sibling for the example), I was not aware of that. I did check SA out, but missed this somehow, so I'm using psycopg2 directly now... But if I gain portability to other DBs for low effort, then I'm all for it. Thanks!

FYI, you can also execute queries directly against a database in SQLAlchemy:

    engine = create_engine('mysql://scott:tiger@localhost/test')
    connection = engine.connect()
    result = connection.execute("select username from users")
    for row in result:
        print("username:", row['username'])
    connection.close()
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.