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 +27 -0
- {db2_hj3415-0.1.6.dist-info → db2_hj3415-0.1.7.dist-info}/METADATA +1 -1
- {db2_hj3415-0.1.6.dist-info → db2_hj3415-0.1.7.dist-info}/RECORD +5 -5
- {db2_hj3415-0.1.6.dist-info → db2_hj3415-0.1.7.dist-info}/WHEEL +0 -0
- {db2_hj3415-0.1.6.dist-info → db2_hj3415-0.1.7.dist-info}/entry_points.txt +0 -0
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)}
|
@@ -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=
|
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.
|
32
|
-
db2_hj3415-0.1.
|
33
|
-
db2_hj3415-0.1.
|
34
|
-
db2_hj3415-0.1.
|
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,,
|
File without changes
|
File without changes
|