2023-12-14 14:22:09,242 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2023-12-14 14:22:09,244 INFO sqlalchemy.engine.Engine SELECT user_account.id, user_account.name
FROM user_account
2023-12-14 14:22:09,246 INFO sqlalchemy.engine.Engine [generated in 0.00123s] {}
(1, 'new user')
2023-12-14 14:22:09,248 INFO sqlalchemy.engine.Engine ROLLBACK
字段别名
stmt = select(("tmpName:"+user_table.c.name).label("realname")).order_by(user_table.c.id)with engine.connect()as conn:for row in conn.execute(stmt):print(row.realname)
2023-12-14 14:31:05,943 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2023-12-14 14:31:05,944 INFO sqlalchemy.engine.Engine SELECT concat(%(name_1)s, user_account.name) AS realname
FROM user_account ORDER BY user_account.id
2023-12-14 14:31:05,945 INFO sqlalchemy.engine.Engine [cached since 43.98s ago] {'name_1': 'tmpName:'}
tmpName:new user
tmpName:user1
tmpName:user2
tmpName:user1
tmpName:user2
tmpName:user1
tmpName:user2
2023-12-14 14:31:05,947 INFO sqlalchemy.engine.Engine ROLLBACK
## 字段表达式
from sqlalchemy import text
stmt = select(user_table.c.id,text("id+100"),text("'id+100'"),)with engine.connect()as conn:result = conn.execute(stmt)for row in result:print(row)
2023-12-14 14:34:46,915 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2023-12-14 14:34:46,916 INFO sqlalchemy.engine.Engine SELECT user_account.id, id+100, 'id+100'
FROM user_account
2023-12-14 14:34:46,917 INFO sqlalchemy.engine.Engine [generated in 0.00169s] {}
(1, 101, 'id+100')
(2, 102, 'id+100')
(3, 103, 'id+100')
(4, 104, 'id+100')
(5, 105, 'id+100')
(8, 108, 'id+100')
(9, 109, 'id+100')
2023-12-14 14:34:46,919 INFO sqlalchemy.engine.Engine ROLLBACK
2023-12-14 16:57:42,724 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2023-12-14 16:57:42,725 INFO sqlalchemy.engine.Engine INSERT INTO user_account (name, fullname) VALUES (%(name)s, %(fullname)s)
2023-12-14 16:57:42,726 INFO sqlalchemy.engine.Engine [cached since 261.2s ago] {'name': 'squidward', 'fullname': 'Squidward Tentacles'}
2023-12-14 16:57:42,728 INFO sqlalchemy.engine.Engine INSERT INTO user_account (name, fullname) VALUES (%(name)s, %(fullname)s)
2023-12-14 16:57:42,728 INFO sqlalchemy.engine.Engine [cached since 261.2s ago] {'name': 'ehkrabs', 'fullname': 'Eugene H. Krabs'}
2023-12-14 16:57:42,730 INFO sqlalchemy.engine.Engine COMMIT
**************************************************
2023-12-14 16:57:42,732 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2023-12-14 16:57:42,733 INFO sqlalchemy.engine.Engine SELECT user_account.id AS user_account_id, user_account.name AS user_account_name, user_account.fullname AS user_account_fullname
FROM user_account
WHERE user_account.id = %(pk_1)s
2023-12-14 16:57:42,733 INFO sqlalchemy.engine.Engine [cached since 84.44s ago] {'pk_1': 26}
26
2023-12-14 16:57:42,735 INFO sqlalchemy.engine.Engine SELECT user_account.id AS user_account_id, user_account.name AS user_account_name, user_account.fullname AS user_account_fullname
FROM user_account
WHERE user_account.id = %(pk_1)s
2023-12-14 16:57:42,736 INFO sqlalchemy.engine.Engine [cached since 84.44s ago] {'pk_1': 27}
27
2023-12-14 16:57:42,737 INFO sqlalchemy.engine.Engine ROLLBACK
删除
session = Session(engine)
patrick = session.get(User,3)
session.delete(patrick)
session.commit()
2023-12-14 17:01:14,641 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2023-12-14 17:01:14,642 INFO sqlalchemy.engine.Engine SELECT user_account.id AS user_account_id, user_account.name AS user_account_name, user_account.fullname AS user_account_fullname
FROM user_account
WHERE user_account.id = %(pk_1)s
2023-12-14 17:01:14,642 INFO sqlalchemy.engine.Engine [cached since 39.91s ago] {'pk_1': 3}
2023-12-14 17:01:14,646 INFO sqlalchemy.engine.Engine DELETE FROM user_account WHERE user_account.id = %(id)s
2023-12-14 17:01:14,647 INFO sqlalchemy.engine.Engine [generated in 0.00076s] {'id': 3}
2023-12-14 17:01:14,650 INFO sqlalchemy.engine.Engine COMMIT
from sqlalchemy import delete
stmt = delete(User).where(User.name.in_(["squidward","sandy"]))
session.execute(stmt)
session.commit()
2023-12-14 17:04:21,096 INFO sqlalchemy.engine.Engine DELETE FROM user_account WHERE user_account.name IN (%(name_1_1)s, %(name_1_2)s)
2023-12-14 17:04:21,098 INFO sqlalchemy.engine.Engine [cached since 15.71s ago] {'name_1_1': 'squidward', 'name_1_2': 'sandy'}
2023-12-14 17:04:21,099 INFO sqlalchemy.engine.Engine COMMIT
修改
from sqlalchemy import update
stmt =(update(User).where(User.name.in_(["squidward","sandy"])).values(fullname="Name starts with S"))
session.execute(stmt)
session.commit()
2023-12-14 17:04:58,832 INFO sqlalchemy.engine.Engine BEGIN (implicit)
2023-12-14 17:04:58,835 INFO sqlalchemy.engine.Engine UPDATE user_account SET fullname=%(fullname)s WHERE user_account.name IN (%(name_1_1)s, %(name_1_2)s)
2023-12-14 17:04:58,836 INFO sqlalchemy.engine.Engine [generated in 0.00123s] {'fullname': 'Name starts with S', 'name_1_1': 'squidward', 'name_1_2': 'sandy'}
2023-12-14 17:04:58,840 INFO sqlalchemy.engine.Engine COMMIT
都知道 linux kernel 无力处理高速网络,但各种 offloading 方案也不全对,所以到底为什么 linux kernel 对高速网络无力。
中断,锁,上下文切换,内存拷贝这些经理都够得着的视野就别烦世人皆俯视了。本文给出另一个视角…
🌈write in front :🔍个人主页 : 啊森要自信的主页 ✏️真正相信奇迹的家伙,本身和奇迹一样了不起啊! 欢迎大家关注🔍点赞👍收藏⭐️留言📝>希望看完我的文章对你有小小的帮助&am…