GBase 8a
其他
文章

Gbase8a实现python异步抽取数据

发表于2024-09-02 09:53:2581次浏览3个评论

# pip install aiomysql  asyncio

import asyncio
import aiomysql
from GBaseConnector import connect, GBaseError

async def fetch_data(host, port, user, password, db, query): 
   conn = await aiomysql.connect(host=host, port=port, user=user, password=password, db=db) 
   async with conn.cursor() as cursor: 
       await cursor.execute(query) 
       return await cursor.fetchall()   
 

thedata=asyncio.run(fetch_data(
   host='192.168.56.195',
   port=5258,
   user='gbase',
   password='gbase20110531',
   db='ssbm',
   query="SELECT * FROM lineorder limit 3005")
   )
 

评论

登录后才可以发表评论
崔哥发表于 9个月前
赞积分,赞积分
用户头像
levvel发表于 6个月前
值得一读!
用户头像
levvel发表于 5个月前
哎呀,怎么说呢,嗯......