Skip to content

gh-118469: Add documentation for sqlite3 PEP-249 constructors #122091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,40 @@ Module functions
Note: *typename* and the name of the type in your query are matched
case-insensitively.

.. function:: Date(year, month, day)

This function constructs an object holding a date value.

.. function:: Time(hour, minute, second)

This function constructs an object holding a time value.

.. function:: Timestamp(year, month, day, hour, minute, second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the second allowed to be fractional or not? (same question for Time())

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my tests, Doing something like this fails:

sqlite3.Time(12, 30, 45.12)

But this succeeds:

sqlite3.Time(12, 30, 45, 12)

However, it is not mentioned in PEP-249. How should we handle that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. I think should definitely be documented and the signature of Time should be something like Time(h, m, s[, ms]) (check the syntax in the time module, I don't remember now).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Re-reading the issue, I believe the intention was to document these constructors per PEP-249. I'm not sure if this is more an implementation detail. Will wait for @erlend-aasland guidance.


This function constructs an object holding a time stamp value.

.. function:: DateFromTicks(ticks)

This function constructs an object holding a date value from the given ticks
value (number of seconds since the epoch; see the documentation of the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it's the UNIX epoch and not Gregorian epoch? Can it be a fractional number of seconds or not?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume it's the UNIX epoch and not Gregorian epoch?

Yeah the UNIX epoch.

Can it be a fractional number of seconds or not?

This was taken from PEP-249. Should we get clarification there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was not considered at that time. In general, we don't change PEPs (unless there is a real issue with the PEP I think, but I am not aware of a precedent). Best is to ask @erlend-aasland: should we leave it imprecise, or is there some assumptions that I'm not aware of?

standard Python :mod:`time` module for details).

.. function:: TimeFromTicks(ticks)

This function constructs an object holding a time value from the given ticks
value (number of seconds since the epoch; see the documentation of the
standard Python :mod:`time` module for details).

.. function:: TimestampFromTicks(ticks)

This function constructs an object holding a time stamp value from the given
ticks value (number of seconds since the epoch; see the documentation of the
standard Python :mod:`time` module for details).

.. function:: Binary(string)

This function constructs an object capable of holding a binary (long) string
value.

.. _sqlite3-module-constants:

Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy