-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
57 lines (48 loc) · 1.64 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import asyncio
from prisma import Prisma
from pyairtable import Table
from os import getenv
from dotenv import load_dotenv
from prisma.enums import *
import prisma.errors
import arrow
load_dotenv()
reg_table = Table(getenv("AIRTABLE_KEY"), "app57E6nIn23rmMHe", "Registrations")
records = reg_table.all()
skills = {
"beginner": technicalSkill.BEGINNER,
"intermediate": technicalSkill.INTERMEDIATE,
"advanced": technicalSkill.ADVANCED
}
sizes = {
"axs": tShirtSize.AXS,
"as": tShirtSize.AS,
"am": tShirtSize.AM,
"al": tShirtSize.AL,
"axl": tShirtSize.AXL
}
async def main() -> None:
db = Prisma()
await db.connect()
for rec in records:
data: Dict = rec['fields']
bday = arrow.get(data["Birthday"], "YYYY-MM-DD").datetime
try:
await db.participant.create(
data={
"email": data['Contact Email'],
"name": data['Name'],
"dob": bday,
"technicalSkill": skills[data['Technical Skill']],
"tShirtSize": sizes[data['T-shirt size']],
"workshop": data.get("Hosting a Workshop", False),
"vaccineStatus": data.get("Vaccination Status", False),
"pronouns": data.get("Your pronouns", None),
"dietaryRestrictions": data.get("Dietary Restrictions", None)
},
)
print(f"created record for {data['Name']}!")
except prisma.errors.UniqueViolationError:
print(f"didnt add {data['Name']} due to duplicate")
if __name__ == "__main__":
asyncio.run(main())