Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'postgresql': 0.07; 'table.': 0.07; 'alter': 0.09; 'sure,': 0.09; 'cc:addr:python- list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'integer,': 0.16; 'subject:dates': 0.16; 'subject:sqlite3': 0.16; 'worst': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'server,': 0.19; 'slightly': 0.19; 'seems': 0.21; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'features,': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'work.': 0.31; 'that.': 0.31; '>>>>': 0.31; 'quite': 0.32; 'becomes': 0.33; 'implemented': 0.33; 'maybe': 0.34; 'could': 0.34; 'basic': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; "didn't": 0.36; 'pm,': 0.38; 'does': 0.39; 'how': 0.40; 'easy': 0.60; 'full': 0.61; 'back': 0.62; 'more': 0.64; 'offer,': 0.65; 'frank': 0.68; 'facilities': 0.69; 'surprise': 0.74; '2015': 0.84; '2015.': 0.91; 'magical': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=v41ZpcECxOeDzrQQsINEzezHXfyDJxf+NKzHQpwofIo=; b=MRRZzA07aX/bMb6JljIo3mLpcuiQyTRiOvIdDkPiswlBrKYMXynU6jEYk3FtxtiG/r ziUIGat2iosrDK9+UvnzTBl/p5G28QjZnNsc9h/2ynK2lNaY54hp9RWI0AtXM4/PC3m2 A5D5dt6y+imOwD8dQt17mxcpZkM26nwmxk/FEboEfeYGbogjdw0wf1/YoTjv5lhe8eQ7 +Iw7M2HwgeHCAjKD0yywdB60cgR1zu6VG7W4dC5dpwJXQky3sscVHRcoM+BosMW4bmNO 5Som97Gk3J+NH5KPQGi+IVcCtkXJUPMaZ1uO2BQiCzMsMNTXgU+l/RoqddpDqSGUcbYz 1rzg== MIME-Version: 1.0 X-Received: by 10.107.160.212 with SMTP id j203mr17815041ioe.43.1424243136600; Tue, 17 Feb 2015 23:05:36 -0800 (PST) In-Reply-To: References: Date: Wed, 18 Feb 2015 18:05:36 +1100 Subject: Re: sqlite3 and dates From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1424243139 news.xs4all.nl 2917 [2001:888:2000:d::a6]:60691 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85771 On Wed, Feb 18, 2015 at 5:19 PM, Frank Millman wrote: > 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. Heh! Looks like the date is implemented as a slightly magical integer, so "cast to date" becomes "cast to integer" and you just get back 2015. Could be really easy to fix, could be nigh impossible... but sure, that seems a reasonable thing to ask for. Worst case, you get told it's not practical. But if you need more facilities than SQLite3 can offer, maybe it's time to move up to a full database server, instead of local files. Switching to PostgreSQL will give you all those kinds of features, plus a lot of other things that I would have thought pretty basic - like ALTER TABLE. It was quite a surprise to learn that SQLite3 didn't support that. ChrisA