[Tutor] Feedback on coding style

Dennis Lee Bieber wlfraed at ix.netcom.com
Mon May 9 21:09:06 EDT 2022


On Tue, 10 May 2022 00:29:49 +0100, Alan Gauld via Tutor <tutor at python.org>
declaimed the following:


>In case anyone is worrying about an obvious gap, sqlite has
>a set of functions for manipulating/comparing dates/times
>which are stored internally as formatted strings.
>
	If the data is a TEXT type... REAL favors using them as Julian Day
number, and INTEGER as Seconds since Jan 1 1970. See section 2.2 of the
linked documentation.

>So although there is no DATETIME type you can still do the
>usual date/time manipulations you'd expect with a database.

	However, the Python module, with proper options, is supposed to handle
conversion of Python datetime.date and datetime.datetime structures in/out
SQLite3 when using "non-supported" "date" and "timestamp" as the data types
in the table definition. Note that I did NOT create a formatted datetime
when providing the timestamp in the INSERT DML (I did not check if the
converters worked on the SELECT DML, all I know is the printed reported had
a formatted datetime and not something like <datetime object ID xxx>)

	Per section 3.1, "date" and "timestamp" both fall under rule #5 and get
the generic NUMERIC affinity (which probably translates to the formatted
string from the converters since such aren't "well-formed" INT or REAL
values <G>)



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/



More information about the Tutor mailing list