Тёмный

Just Use Pydantic 

John Watson Rooney
Подписаться 86 тыс.
Просмотров 25 тыс.
50% 1

Pydantic is great for data validation and parsing, giving us a much better option that standard for working with data in Python. In this video I will show you how to create Pydantic models from shopify product json where we don't want to include large amounts of the data. by adding in to our models only the fields we are interested in we can omit the rest of the data and avoid having to write and rewrite complex indexing and gets on our dictionary, improving readability and usage
Scraper API www.scrapingbe...

Опубликовано:

 

27 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 29   
@Julian-sn9vc
@Julian-sn9vc Год назад
Hi! Great video on scraping Shopify data into Pydantic Models! I'm considering using Pydantic with an API and SqlAlchemy for my project. Could you create a follow-up video on mapping Pydantic Models to SqlAlchemy models and then writing the data into a database? This would be incredibly helpful. Thanks!
@JohnWatsonRooney
@JohnWatsonRooney Год назад
Great thanks! Sure i will do a follow up to include sqla!
@Hellbending
@Hellbending Год назад
Might be worth doing using fastAPI then ;)
@hoeszyslak6989
@hoeszyslak6989 9 месяцев назад
just save your self tons of quality of life issues and use attrs and cattrs instead of pydantic + you get good performance while still keeping your project entirely python... the new pydantic uses rust to solve some problems that attrs already solved ages ago. And it's more reliable because NASA uses it on it's mars rover.
@bramjanssen8865
@bramjanssen8865 Месяц назад
Hey! I'm just starting to work with Python. I know this is not directly related to this video, but how do you "pretty print" those values in terminal?
@JohnWatsonRooney
@JohnWatsonRooney Месяц назад
I use the package “rich” to print - pip install rich, then in your code from rich import print, and then print() as normal
@bramjanssen8865
@bramjanssen8865 Месяц назад
@@JohnWatsonRooney thnx alot!!
@oerickmuller
@oerickmuller 9 месяцев назад
Awesome content, concise and helpful. Thanks!
@MrPsychoTreatment
@MrPsychoTreatment Год назад
Hi John, great tutorial! Is there any reason to use Pydantic over Dataclasses?
@AnthonyBecker9
@AnthonyBecker9 4 месяца назад
Pydantic gives you powerful data validation and error messages.
@HermannWinter
@HermannWinter 6 месяцев назад
excellent 👍
@yafethtb
@yafethtb Год назад
Can we do this with dataclasses instead?
@JohnWatsonRooney
@JohnWatsonRooney Год назад
Yes but you don’t get validation
@yafethtb
@yafethtb Год назад
@@JohnWatsonRooney is it like __post_init in dataclasses?
@JessicaNg-v4s
@JessicaNg-v4s Год назад
I have tried the same method using the dataclasses. I got issue that when declaring the `Product` dataclass, it requires to declare all the attributes in the JSON response, not just `ID` and `title` like in your example.
@julians.2597
@julians.2597 7 месяцев назад
it's great, but it very slow, by an order of magnitude more than plain classes, simple namespace, named tuples, dataclasses, attrs, etc. So use it for parsing and validation for which it's made and great, but don't use it as a general purpose data structure.
@ricardor8044
@ricardor8044 Год назад
What font do you use ? It looks so unique
@SAMWELLFPS
@SAMWELLFPS Год назад
please do a Bet 305 odds and how to scrap it
@ZainAli-hq1gu
@ZainAli-hq1gu Год назад
upload the on your repo
@thebuggser2752
@thebuggser2752 8 месяцев назад
Neat!
@younesboukroun3060
@younesboukroun3060 9 месяцев назад
pwerful yeh
@graczew
@graczew Год назад
Good content as always. 👍👍👍
@JohnWatsonRooney
@JohnWatsonRooney Год назад
thanks mate i appreciate it
@JessicaNg-v4s
@JessicaNg-v4s Год назад
I have tried the same method using the dataclasses. I got issue that when declaring the `Product` dataclass, it requires to declare all the attributes in the JSON response, not just `ID` and `title` like in your example.
@ericxls93
@ericxls93 Год назад
Will try this! Thank you. I have use the Spotify rest, but somehow I find their API super convoluted… getting sales and refunds by day is an industry 🤦‍♂️
@aktiecase
@aktiecase 3 месяца назад
this is so good, thank you
@ErikS-
@ErikS- 11 месяцев назад
brilliant example!
@techatival
@techatival Год назад
Sholdn't be the price mapped to a float instead of a string?
@roshantarot
@roshantarot Год назад
I m not getting didi website data getting 501 response can u give me suggestions please
Далее
Меня Забанили в Steam CS2 / PUBG
19:19
Просмотров 157 тыс.
This is How I Scrape 99% of Sites
18:27
Просмотров 79 тыс.
OpenAI Structured Output - All You Need to Know
24:46
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
Best Web Scraping Combo? Use These In Your Projects
20:13
Pydantic is OP, here's why
18:10
Просмотров 23 тыс.
Liked Pydantic? You'll LOVE Msgspec
15:53
Просмотров 12 тыс.
Pydantic is all you need: Jason Liu
17:55
Просмотров 179 тыс.
Why You Should Use Pydantic in 2024 | Tutorial
13:56
Просмотров 72 тыс.
Меня Забанили в Steam CS2 / PUBG
19:19
Просмотров 157 тыс.