Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #61330
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.020 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; 'converted': 0.09; 'subject:extra': 0.09; 'wrote': 0.14; '-tkc': 0.16; 'defined.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'igor': 0.16; 'skip:d 60': 0.16; 'sqlite': 0.16; 'subject:variable': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'print': 0.22; 'string,': 0.24; 'purposes': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'skip:( 20': 0.30; 'probably': 0.32; 'text': 0.33; 'table': 0.34; 'maybe': 0.34; 'skip:d 20': 0.34; 'but': 0.35; 'dates': 0.36; 'processed': 0.36; 'charset:us- ascii': 0.36; 'should': 0.36; 'window': 0.38; 'to:addr:python- list': 0.38; '12,': 0.39; 'subject:" ': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'engines': 0.60; 'tell': 0.60; 'today': 0.64; 'kept': 0.65; 'between': 0.67; 'received:50.22': 0.84 |
| Date | Sun, 8 Dec 2013 16:18:58 -0600 |
| From | Tim Chase <python.list@tim.thechases.com> |
| To | python-list@python.org |
| Subject | Re: Eliminate "extra" variable |
| In-Reply-To | <CA+FnnTwSKYs-RAqVT-fZpotte30+xC-oUx-qnidw_qA=uv+KSA@mail.gmail.com> |
| References | <CA+FnnTzDjRzU65+VWnOwxfVR9FGMDgHLLmLEDOoGE0BMCptzEw@mail.gmail.com> <52A25D94.9040404@islandtraining.com> <CA+FnnTxxJc2J1SF0UHXo1DkZPdN0W5iWhOgBYzfbW1T0GtaSgg@mail.gmail.com> <CA+FnnTzBYp5Fvy1ohCySLitbL21+hHdfur9=oF4TM+Skeu-XJw@mail.gmail.com> <CA+FnnTzkHYNN_rgLaaXwvod9qGhetXRy+3v96+5+wEyhCq0LwA@mail.gmail.com> <CA+FnnTwZ3aF++ZzaAJzG0Y98usfLTge0KTzj14LfqDgh1OnsZQ@mail.gmail.com> <20131208125823.241112db@bigbox.christie.dr> <mailman.3738.1386529877.18130.python-list@python.org> <roy-E243A9.15072508122013@news.panix.com> <CA+FnnTyZzrhwkLvsY0EdvXD_PoTWK45C0=peWGWtse1uEwJC=Q@mail.gmail.com> <CA+FnnTwSKYs-RAqVT-fZpotte30+xC-oUx-qnidw_qA=uv+KSA@mail.gmail.com> |
| X-Mailer | Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-AntiAbuse | This header was added to track abuse, please include it with any abuse report |
| X-AntiAbuse | Primary Hostname - boston.accountservergroup.com |
| X-AntiAbuse | Original Domain - python.org |
| X-AntiAbuse | Originator/Caller UID/GID - [47 12] / [47 12] |
| X-AntiAbuse | Sender Address Domain - tim.thechases.com |
| X-Get-Message-Sender-Via | boston.accountservergroup.com: authenticated_id: tim@thechases.com |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3745.1386541065.18130.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1386541065 news.xs4all.nl 2943 [2001:888:2000:d::a6]:59260 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:61330 |
Show key headers only | View raw
On 2013-12-08 12:58, Igor Korot wrote:
> Also, the data comes from either SQLite or mySQL and so to eliminate
> the difference between those engines dates are processed as strings
> and converted to dates for the calculation purposes only.
> Maybe I will need to refactor SQLite processing to get the dates as
> dates and not a string, but that's probably for the future. so that
> dates will be kept as the datetime type until the end of the
> function. As I wrote the dates will be used as the text for the
> plotting window axis labels and as the labels they should come out
> as strings, hence the conversion.
Sqlite can do this automatically if you tell it to upon connecting:
>>> import sqlite3
>>> conn = sqlite3.connect('x.sqlite',
... detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>>> cur.execute("create table foo (s date);")
<sqlite3.Cursor object at 0x7f7f31665570>
>>> import datetime
>>> today = datetime.date.today()
>>> cur.execute("insert into foo(s) values (?)", (today,))
<sqlite3.Cursor object at 0x7f7f31665570>
>>> cur.execute("select * from foo")
<sqlite3.Cursor object at 0x7f7f31665570>
>>> r = cur.fetchone()
>>> print r
(datetime.date(2013, 12, 8),)
Note that it returns a datetime.date, the same as it was defined.
-tkc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Eliminate "extra" variable Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-12-08 19:10 +0000
Re: Eliminate "extra" variable Roy Smith <roy@panix.com> - 2013-12-08 15:07 -0500
Fwd: Eliminate "extra" variable Igor Korot <ikorot01@gmail.com> - 2013-12-08 12:58 -0800
Re: Eliminate "extra" variable Tim Chase <python.list@tim.thechases.com> - 2013-12-08 16:18 -0600
Re: Fwd: Eliminate "extra" variable Dave Angel <davea@davea.name> - 2013-12-08 17:36 -0500
Re: Eliminate "extra" variable Igor Korot <ikorot01@gmail.com> - 2013-12-14 23:49 -0800
Re: Eliminate "extra" variable Tim Chase <python.list@tim.thechases.com> - 2013-12-15 06:17 -0600
Re: Eliminate "extra" variable Tim Chase <python.list@tim.thechases.com> - 2013-12-15 06:29 -0600
Re: Eliminate "extra" variable Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-15 12:08 -0500
Re: Eliminate "extra" variable Igor Korot <ikorot01@gmail.com> - 2013-12-15 14:46 -0800
Re: Eliminate "extra" variable MRAB <python@mrabarnett.plus.com> - 2013-12-16 00:58 +0000
Re: Eliminate "extra" variable Igor Korot <ikorot01@gmail.com> - 2013-12-15 18:43 -0800
Re: Eliminate "extra" variable Dave Angel <davea@davea.name> - 2013-12-15 21:58 -0500
Re: Eliminate "extra" variable Chris Angelico <rosuav@gmail.com> - 2013-12-16 13:57 +1100
Re: Eliminate "extra" variable Igor Korot <ikorot01@gmail.com> - 2013-12-15 20:24 -0800
csiph-web