🕵️ Reverse EngineeringHow not to solve Jane Street's ASIC puzzle. Kinda.(17.09.2026 um 21:27 Uhr)
🔧 ProgrammierungHTMX is fine until the third stakeholder wants a modal(17.09.2026 um 21:13 Uhr)
🕵️ Reverse EngineeringHow not to solve Jane Street's ASIC puzzle. Kinda.(17.09.2026 um 21:27 Uhr)
🔧 ProgrammierungHTMX is fine until the third stakeholder wants a modal(17.09.2026 um 21:13 Uhr)
🔧 Programmierung 🕛 vor 9 Monaten 3 Min Lesezeit
0

How have I managed Date types in my asyncio python web scraper using PostgreSQL?

↗ Quelle (dev.to)
🗣️ Stimme:
📺
dev.to

*Hi there! It is my first post here so today I'll be talking about Date types managemnt in PostgreSQL, as example it will be my own web scraper.

Firstly, let us cover the basics. *



1. A recommended format of data storage in PostgreSQL

The standard SQL convention is to use that can be stored in PostgreSQL , by the way, PostgreSQL provides a lot of convenient features for managing date types, especially, that is why I have moved my scraper from SQLite to PostgreSQL. If you deal with timestamptz (see box) , basically , in Python it is something similar to datetime obj. You must explicitly specify wether it is with or without timezone, because PostgreSQL never examines the content of a literal string before determining its type. You must pay attention, if you are using some dates in YMD related formats as it would be more memory efficient to use a "Date" type for them , despite of timestamptz.

, before making input into the database. It is used as an international , universal unit of measurement.

Imagine the situation: you scrape two websites with different timezones -one has European, the other American. Of course, you can specify an offset and maybe a specific timezone, but why bother when you can just store them in UTC? Therefore, if a user is from the USA, you should specify their local timezone when outputting the timestamptz data.

In my example, first, I converted the raw string into a Python datetime object and defined the timezone offset (e.g., 2025-11-27 09:36:32+01:00). Second, I converted it to UTC. Here is the relevant code:




CODE
def datetime_utc_converter(datetime_obj: datetime) -> datetime:
return datetime_obj.astimezone(tz=timezone.utc)






With this approach, I am sure my data is managed in a correct, non-ambiguous way.



3. How PostgreSQL client (pgadmin in my example) show your data?

This can be one of the most confusing parts in today's article for beginners: you may insert data in UTC, but the data will be shown in your local or the specified timezone.

For the default timezone, PostgreSQL uses the default parameter specified in postgresql.conf. You may see its location by running this query in psql:

SHOW config_file

Then you may change the default value. If you want to see already set parameter, then use:

SHOW timezone

You may see available timezones by:

SELECT * FROM pg_timezone_names

And set one of them by:

e.g SET 'America/Araguaina' choose one that you need.

It is recommended to set your default timezone to UTC.



Overall, hope you enjoyed my small article, the whole information was taken from PostgreSQL docs about the topic.

I look forward to all your questions and additions, and please correct me if I am wrong somewhere!

Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Microsoft gibt Fehler zu – Vorsicht! Windows-Update sperrt Nutzer vom PC aus - Heute.at
1 Quelle
How not to solve Jane Street's ASIC puzzle. Kinda.
1 Quelle
Revolut-Hacker fordern 6.000 Monero nach Datendiebstahl - Kryptorevolution
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How have I managed Date types in my asyncio python web scraper using PostgreSQL?

Thematisch verwandte Begriffe: have, managed, Date, types · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...