You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import asyncio
import sqlalchemy as sa
from aiomysql.sa import create_engine
metadata = sa.MetaData()
tbl = sa.Table('tbl', metadata,
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('val', sa.String(255)))
@asyncio.coroutine
def go():
engine = yield from create_engine(user='root',
db='dabbot',
host='db',
password='dabbot')
with (yield from engine) as conn:
yield from conn.execute(tbl.insert().values(val='abc'))
res = yield from conn.execute(tbl.select())
for row in res:
print(row.id, row.val)
asyncio.get_event_loop().run_until_complete(go())
I was following https://github.com/aio-libs/aiomysql/blob/master/docs/sa.rst and I noticed that running the example multiple times did not work as expected.
The example:
Then I opened up adminer and added
6 def
I think the example is missing
conn.execute('commit')
.The example at https://github.com/aio-libs/aiomysql/blob/master/examples/example_simple_sa.py has the same issue. I removed the "drop" statement and it doesn't persist rows like I expect.
The text was updated successfully, but these errors were encountered: