Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

how to insert into existing database postgresql sqlalchemy python

engine = create_engine('postgresql://username@localhost/dbName')
    with engine.connect() as conn:
        metaDats = MetaData(conn, schema="optionalSchemaHere")
        metaDats.reflect(bind=conn)
        table = metaDats.tables['optionalSchemaHere.tableName']
        stmt = table.insert().values(id='optionalId', column2="name", etc...)
        conn.execute(stmt)
 
PREVIOUS NEXT
Tagged: #insert #existing #database #postgresql #sqlalchemy #python
ADD COMMENT
Topic
Name
9+6 =