Giter Site home page Giter Site logo

Comments (8)

AA1999 avatar AA1999 commented on June 7, 2024

Also sidenote: ibpqxx.readthedocs.io/en/stable is dead as we speak

from libpqxx.

tt4g avatar tt4g commented on June 7, 2024

Not supported as far as I know.
I assume that this is because the time that std::chrono::time_point is based on is platform-dependent, and the time zone and format of TIMESTAMP retrieved from PostgreSQL is configuration-dependent, making it difficult for libpqxx to parse the time string.

from libpqxx.

jtv avatar jtv commented on June 7, 2024

There is built-in support for std::chrono::year_month_day and friends, but that's about it. The system for supporting data types is extensible though — see include/pqxx/doc/datatypes.md.

from libpqxx.

jtv avatar jtv commented on June 7, 2024

Thanks for the warning about readthedocs.io... As far as I can tell the class documentation is there, but not the indexes.

from libpqxx.

AA1999 avatar AA1999 commented on June 7, 2024

There is built-in support for std::chrono::year_month_day and friends, but that's about it. The system for supporting data types is extensible though — see include/pqxx/doc/datatypes.md.

What if I do .as<std::string>() on the timestamp row? Would it return a specific format?

from libpqxx.

tt4g avatar tt4g commented on June 7, 2024

The column values received from the database are in string format.
TIMESTAMP is in ISO format (default).

https://www.postgresql.org/docs/16/datatype-datetime.html#DATATYPE-DATETIME-OUTPUT

The output format of the date/time types can be set to one of the four styles ISO 8601, SQL (Ingres), traditional POSTGRES (Unix date format), or German. The default is the ISO format. (The SQL standard requires the use of the ISO 8601 format. The name of the “SQL” output format is a historical accident.) Table 8.14 shows examples of each output style. The output of the date and time types is generally only the date or time part in accordance with the given examples. However, the POSTGRES style outputs date-only values in ISO format.

from libpqxx.

jtv avatar jtv commented on June 7, 2024

In other words: the database sends the data in a human-readable text format (in the case of a timestamp: in ISO-8601 format), and so from libpqxx's standpoint all data in a result are already strings. If you request it using .as<std::string>(), you simply get that string exactly as you would hope.

The part that's more complicated is if you want to convert the string that the database sent to a C++ type that libpqxx doesn't yet support. (Or going the other way: if you want to pass such an object as a parameter to an SQL statement.) However it is possible for an application to "inject" support for additional data types.

from libpqxx.

jtv avatar jtv commented on June 7, 2024

I hope this has been resolved. Closing the ticket.

from libpqxx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.