from dao.db.util import get_connet def exmaple_query(): with get_connet() as conn: cursor = conn.cursor() cursor.execute("select * from user") for row in cursor.fetchall(): print(row) cursor.close() def exmaple_insert(): with get_connet() as conn: with conn.cursor() as cursor: cursor.execute("insert into user(name, age) values('test', 18)") conn.commit() cursor.close() def exmaple_update(): with get_connet() as conn: with conn.cursor() as cursor: cursor.execute("update user set age=19 where name='test'") conn.commit() cursor.close()