Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql connect timeout #1552

Merged
merged 3 commits into from
Aug 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions stix_shifter_modules/mysql/stix_transmission/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async def ping_data_source(self):
try:
pool = await aiomysql.create_pool(host=self.host, port=self.port,
user=self.user, password=self.password,
db=self.database)
db=self.database, connect_timeout=self.timeout)
async with pool.acquire() as conn:
async with conn.cursor() as cur:
await cur.execute("SELECT 42;")
Expand All @@ -47,7 +47,7 @@ async def run_search(self, query, start=0, rows=0):
try:
pool = await aiomysql.create_pool(host=self.host, port=self.port,
user=self.user, password=self.password,
db=self.database)
db=self.database, connect_timeout=self.timeout)
async with pool.acquire() as conn:
async with conn.cursor() as cursor:
column_query = "SHOW COLUMNS FROM %s" % self.table
Expand All @@ -60,8 +60,9 @@ async def run_search(self, query, start=0, rows=0):
# Uncomment to see data on newly populated table
# query = "select * from {} limit 1".format(self.table)

await cursor.execute(query)
result_collection = await cursor.fetchall()
await cursor.execute(query)
result_collection = await cursor.fetchall()

results_list = []
row_count = int(rows)

Expand Down
Loading