Ridealist commited on
Commit
011ddbd
1 Parent(s): 8758298

feat: apply streamlit cache to connectiong DB

Browse files
Files changed (1) hide show
  1. modules/db_modules.py +1 -3
modules/db_modules.py CHANGED
@@ -14,8 +14,8 @@ else:
14
  AWS_SECRET_ACCESS_KEY = st.secrets['AWS_SECRET_ACCESS_KEY']
15
 
16
 
 
17
  def get_db():
18
-
19
  dynamodb = boto3.resource(
20
  'dynamodb',
21
  region_name='ap-northeast-2',
@@ -26,7 +26,6 @@ def get_db():
26
 
27
  return dynamodb
28
 
29
- # put_item
30
  def put_item(table, item):
31
 
32
  print("item", item)
@@ -38,7 +37,6 @@ def put_item(table, item):
38
  else:
39
  print('Error inserting item')
40
 
41
- # get_item
42
  def get_item(table, item):
43
 
44
  response = table.get_item(Key=item)
 
14
  AWS_SECRET_ACCESS_KEY = st.secrets['AWS_SECRET_ACCESS_KEY']
15
 
16
 
17
+ @st.cache_resource
18
  def get_db():
 
19
  dynamodb = boto3.resource(
20
  'dynamodb',
21
  region_name='ap-northeast-2',
 
26
 
27
  return dynamodb
28
 
 
29
  def put_item(table, item):
30
 
31
  print("item", item)
 
37
  else:
38
  print('Error inserting item')
39
 
 
40
  def get_item(table, item):
41
 
42
  response = table.get_item(Key=item)