Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!81.171.88.16.MISMATCH!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'filing': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'type,': 0.09; 'python': 0.11; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:dates': 0.16; 'subject:sqlite3': 0.16; "test')": 0.16; 'module': 0.19; '>>>': 0.22; 'import': 0.22; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'feature': 0.29; 'skip:( 20': 0.30; 'work.': 0.31; 'table': 0.34; 'could': 0.34; 'test': 0.35; 'but': 0.35; 'to:addr:python- list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'easy': 0.60; 'providing': 0.61; 'worth': 0.66; 'frank': 0.68 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: "Frank Millman" Subject: sqlite3 and dates Date: Wed, 18 Feb 2015 08:19:25 +0200 X-Gmane-NNTP-Posting-Host: 197.86.206.166 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.4657 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4913 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424240380 news.xs4all.nl 2921 [2001:888:2000:d::a6]:54463 X-Complaints-To: abuse@xs4all.nl X-Received-Body-CRC: 471742652 X-Received-Bytes: 3321 Xref: csiph.com comp.lang.python:85770 Hi all sqlite3 does not have a DATE type, but the python module does a pretty good job of providing one - >>> import sqlite3 >>> conn = sqlite3.connect(':memory:', detect_types=sqlite3.PARSE_DECLTYPES) >>> cur = conn.cursor() >>> cur.execute('CREATE TABLE test (dob DATE)') >>> cur.execute('INSERT INTO TEST (dob) VALUES (?)', ('2015-03-31',)) >>> cur.execute('SELECT * FROM test') >>> cur.fetchone() (datetime.date(2015, 3, 31),) >>> However, the following does not return a date object - >>> cur.execute('SELECT CAST(? AS DATE)', ('2015-03-31',)) >>> cur.fetchone() (2015,) >>> I don't know how easy this would be to implement, but it would be nice if it could be made to work. Is it worth filing a feature request? Frank Millman