"""
INSERT INTO example_table
    (id, name)
SELECT 1, 'John'
WHERE
    NOT EXISTS (
        SELECT id FROM example_table WHERE id = 1
    );
"""
m = MetaData()
example_table = Table('example_table', m, Column('id', Integer), Column(
    'name', String))
Postgresql - Insert into where not exists using sqlalchemy's INSERT from SELECT