Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #72688
| Path | csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'python)': 0.05; 'calls.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'sql,': 0.09; 'statements': 0.09; 'url:github': 0.09; 'wrapped': 0.09; 'subject:How': 0.10; 'python': 0.11; 'def': 0.12; 'programs.': 0.14; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'sqlite': 0.16; 'subject:sqlite3': 0.16; 'url:py': 0.16; 'url:svn': 0.16; 'wrote:': 0.18; 'skip:p 40': 0.19; 'url:view': 0.20; 'work,': 0.20; 'written': 0.21; 'print': 0.22; 'header:User- Agent:1': 0.23; 'replace': 0.24; '(or': 0.24; "i've": 0.25; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'subject:) ': 0.29; "i'm": 0.30; 'code': 0.31; 'comments': 0.31; "skip:' 10": 0.31; 'url:python': 0.33; 'could': 0.34; 'subject: (': 0.35; 'but': 0.35; 'doing': 0.36; 'url:org': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'changed': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'how': 0.40; 'new': 0.61; 'subject:more': 0.64; 'sample': 0.67; 'gotten': 0.74; 'improved.': 0.84; 'object:': 0.84; 'url:master': 0.84; 'url:sandbox': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: How to use SQLite (sqlite3) more efficiently |
| Date | Thu, 05 Jun 2014 09:48:22 +0200 |
| Organization | None |
| References | <6e18a509-9471-4fe8-8664-3c58fc17536f@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p57bd82ef.dip0.t-ipconnect.de |
| User-Agent | KNode/4.11.5 |
| 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.10728.1401954515.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1401954515 news.xs4all.nl 2914 [2001:888:2000:d::a6]:52013 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:72688 |
Show key headers only | View raw
ps16thypresenceisfullnessofjoy@gmail.com wrote:
> I'm completely new to SQL, and recently started using SQLite in one of my
> Python programs. I've gotten what I wanted to work, but I'm not sure if
> I'm doing it in the best/most efficient way. I have attached some sample
> code and would appreciate any (polite) comments about how the SQL (or
> Python) in it could be improved. The code is written in Python 2, but I
> think it should work in Python 3 if the 4 print statements are changed to
> function calls. Am I correct that the function 'set_description2' should
> work the same way as 'set_description'?
> def set_description2(conn, name, description):
> with conn:
> if description:
> conn.execute("INSERT OR REPLACE INTO ProgrammingLanguages " \
> "VALUES(?,?)", (name, description))
> else:
> conn.execute("DELETE FROM ProgrammingLanguages WHERE Name=?",
> (name,))
> conn.commit()
Have a look at these to see how this can be wrapped into a dict-like object:
http://svn.python.org/view/sandbox/trunk/dbm_sqlite/alt/dbsqlite.py?view=markup
https://github.com/shish/sqliteshelf/blob/master/sqliteshelf.py
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
How to use SQLite (sqlite3) more efficiently ps16thypresenceisfullnessofjoy@gmail.com - 2014-06-04 13:27 -0700
Re: How to use SQLite (sqlite3) more efficiently Chris Angelico <rosuav@gmail.com> - 2014-06-05 07:23 +1000
Re: How to use SQLite (sqlite3) more efficiently Rustom Mody <rustompmody@gmail.com> - 2014-06-04 19:15 -0700
Re: How to use SQLite (sqlite3) more efficiently Demian Brecht <demianbrecht@gmail.com> - 2014-06-04 20:35 -0700
Re: How to use SQLite (sqlite3) more efficiently Chris Angelico <rosuav@gmail.com> - 2014-06-05 17:08 +1000
Re: How to use SQLite (sqlite3) more efficiently Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-06-04 22:40 -0400
Re: How to use SQLite (sqlite3) more efficiently Peter Otten <__peter__@web.de> - 2014-06-05 09:48 +0200
csiph-web