db2_hj3415 0.1.6__py2.py3-none-any.whl → 0.1.7__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
db2_hj3415/nfs/dart.py CHANGED
@@ -0,0 +1,27 @@
1
+ from motor.motor_asyncio import AsyncIOMotorClient
2
+ from pymongo import InsertOne
3
+ from db2_hj3415.nfs import Dart, DB_NAME, get_collection
4
+
5
+ COL_NAME = "dart"
6
+
7
+ async def save_many(many_data: list[Dart], client: AsyncIOMotorClient) -> dict:
8
+ if not many_data:
9
+ return {"inserted_count": 0, "skipped": 0}
10
+
11
+ collection = get_collection(client, DB_NAME, COL_NAME)
12
+
13
+ # unique index 보장용 (이미 설정되었는지 확인)
14
+ await collection.create_index("rcept_no", unique=True)
15
+
16
+ ops = []
17
+ skipped = 0
18
+
19
+ for item in many_data:
20
+ doc = item.model_dump(mode="json", exclude={"id"}) # _id는 제외
21
+ ops.append(InsertOne(doc))
22
+
23
+ try:
24
+ result = await collection.bulk_write(ops, ordered=False)
25
+ return {"inserted_count": result.inserted_count, "skipped": skipped}
26
+ except Exception as e:
27
+ return {"error": str(e)}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: db2_hj3415
3
- Version: 0.1.6
3
+ Version: 0.1.7
4
4
  Summary: Gathering the stock data by playwright
5
5
  Author-email: Hyungjin Kim <hj3415@gmail.com>
6
6
  Description-Content-Type: text/markdown
@@ -26,9 +26,9 @@ db2_hj3415/nfs/c103.py,sha256=NY2e_BTfSHkELIEUJ8XhhYdNETQaRGOrF4qNaewB2_E,1460
26
26
  db2_hj3415/nfs/c104.py,sha256=aVLchUoxomlthS7FZ0adskBXmxIWQISGfc2EgWkWZDI,1460
27
27
  db2_hj3415/nfs/c106.py,sha256=dAVSnEM5E-sJZExMTfqDoQlozTtH05JOtenzbIUdvtQ,1460
28
28
  db2_hj3415/nfs/c108.py,sha256=F_kP1HMhpe9E6VKm_m-aDl6PZ-FqVs5-O2_-rU8f34Y,3761
29
- db2_hj3415/nfs/dart.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
+ db2_hj3415/nfs/dart.py,sha256=yaqs7Qt8AYzbKWdPSNsaryOBOpVmNudTooBEaj2N-aY,876
30
30
  db2_hj3415/nfs/models.py,sha256=nzoFbkoC58JGL79kcTZyTBheSRAdhPTDZZO36aDi3HU,4934
31
- db2_hj3415-0.1.6.dist-info/entry_points.txt,sha256=JAGFsxKtvbNgaKCSKo-QRYwCyToabWmdRW0MZWtg9kg,45
32
- db2_hj3415-0.1.6.dist-info/WHEEL,sha256=Dyt6SBfaasWElUrURkknVFAZDHSTwxg3PaTza7RSbkY,100
33
- db2_hj3415-0.1.6.dist-info/METADATA,sha256=XncrQbOZUZGqR8KHd_wweoeIpoyL8zdQmcVWKH2KOEI,709
34
- db2_hj3415-0.1.6.dist-info/RECORD,,
31
+ db2_hj3415-0.1.7.dist-info/entry_points.txt,sha256=JAGFsxKtvbNgaKCSKo-QRYwCyToabWmdRW0MZWtg9kg,45
32
+ db2_hj3415-0.1.7.dist-info/WHEEL,sha256=Dyt6SBfaasWElUrURkknVFAZDHSTwxg3PaTza7RSbkY,100
33
+ db2_hj3415-0.1.7.dist-info/METADATA,sha256=dnP69gfUyRZSEeqR5Vd1aJcTyr7CBl1ycF3uUsnMD60,709
34
+ db2_hj3415-0.1.7.dist-info/RECORD,,