Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Frank Millman
"Skip Montanaro" wrote in message news:canc-5uz2ruxrwnax8pjevqztqbndc0aojz3ggeb04k1zfff...@mail.gmail.com... Assuming the underlying database supports transactions, is there any difference between calling the commit() method on the connection and calling the execute method on the cursor with

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Frank Millman
"Frank Millman" wrote in message news:ogr3ff$sg1$1...@blaine.gmane.org... By default, psycopg2 uses 'autocommit', which means that even a SELECT is preceded by a 'BEGIN' statement internally. I never changed the default, so all of the following assumes that autocommit is on. Oops - by default

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Chris Angelico
On Fri, Jun 2, 2017 at 5:18 PM, Frank Millman wrote: > As I said, I cannot prove this, but the theory fits the observed behaviour > perfectly, so I have proceeded on the assumption that it is true. Therefore > I now always run every SQL command or block of commands within a context > manager, whic

Re: Working with dictionaries and keys help please!

2017-06-02 Thread Gregory Ewing
On Thu, 1 Jun 2017 10:29 am, David D wrote: Is there a way of performing this where the key will update so that is continues to work sequentially? It sounds like you don't want a dictionary at all, you want a list. You can use the index() method to find the current "key" of an entry. >>> peop

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Gregory Ewing
Chris Angelico wrote: Executing a query gives you some sort of object. That object either contains all the results, or has the resource handle (or whatever) needed to fetch more from the back end. That basically makes it a cursor, so we're not far different after all :) The point is that my API

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Gregory Ewing
Frank Millman wrote: I never changed the default, so all of the following assumes that autocommit is on. I had many SELECT's, but I was not issuing any form of commit, so the locks built up. I solved my problem by always committing. Something is screwy when a feature called "autocommit" resu

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Chris Angelico
On Fri, Jun 2, 2017 at 6:10 PM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> Executing a query gives you some sort of object. That object either >> contains all the results, or has the resource handle (or whatever) >> needed to fetch more from the back end. That basically makes it a >> curso

Re: Circular iteration on tuple starting from a specific index

2017-06-02 Thread guillaume . paulet
@Gregory Ewing: you were right, your version without *chain* is faster and I quiet like it :) ``` from timeit import timeit from itertools import chain, cycle, islice def cycle_once_with_chain(sequence, start): return chain(islice(sequence, start, None), islice(sequence, start)) def cy

Re: [OT] How to improve my programming skills?

2017-06-02 Thread Adriaan Renting
Adriaan Renting| Email: rent...@astron.nl Software Engineer Radio Observatory ASTRON | Phone: +31 521 595 100 (797 direct) P.O. Box 2 | GSM: +31 6 24 25 17 28 NL-7990 AA Dwingeloo | FAX: +31 521 595 101 The Netherlands| Web: http://www.astron.nl/

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Jon Ribbens
On 2017-06-02, Frank Millman wrote: > "Frank Millman" wrote in message news:ogr3ff$sg1$1...@blaine.gmane.org... > >> By default, psycopg2 uses 'autocommit', which means that even a SELECT is >> preceded by a 'BEGIN' statement internally. I never changed the default, so >> all of the following ass

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Neil Cerutti
On 2017-06-02, Frank Millman wrote: > As I said, I cannot prove this, but the theory fits the > observed behaviour perfectly, so I have proceeded on the > assumption that it is true. Therefore I now always run every > SQL command or block of commands within a context manager, > which always calls

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Jon Ribbens
On 2017-06-02, Dennis Lee Bieber wrote: > Connector/Python (MySQL) [guess it is time for me to finally upgrade to > Python 3.x -- it was the delay in getting mysqldb ported that held me back] > does allow for turning on autocommit -- which is documented as issuing an > implicit commit after

Re: Manager for project templates, that allows "incremental" feature addition

2017-06-02 Thread Lele Gaifax
Lele Gaifax writes: > Paul Moore writes: > >> On Thursday, 23 March 2017 15:56:43 UTC, Paul Moore wrote: >> >> Sadly, it doesn't support Windows, which is what I use. > > FYI, I just saw https://pypi.python.org/pypi/what/0.4.0, that seems an > alternative port of Inquirer.js. Unfortunatel

Bug or intended behavior?

2017-06-02 Thread sean . dizazzo
Can someone please explain this to me? Thanks in advance! ~Sean Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> print "foo %s" % 1-2 Traceback (most rece

Re: Bug or intended behavior?

2017-06-02 Thread Jussi Piitulainen
sean.diza...@gmail.com writes: > Can someone please explain this to me? Thanks in advance! > > ~Sean > > > Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) > [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin > Type "help", "copyright", "credits" or "license" for more information.

Re: Bug or intended behavior?

2017-06-02 Thread justin walters
On Fri, Jun 2, 2017 at 10:17 AM, wrote: > Can someone please explain this to me? Thanks in advance! > > ~Sean > > > Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) > [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin > Type "help", "copyright", "credits" or "license" for more info

Re: Bug or intended behavior?

2017-06-02 Thread Irmen de Jong
On 2-6-2017 19:17, sean.diza...@gmail.com wrote: > Can someone please explain this to me? Thanks in advance! > > ~Sean > > > Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) > [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin > Type "help", "copyright", "credits" or "license" fo

Re: Bug or intended behavior?

2017-06-02 Thread bob gailer
On 6/2/2017 1:28 PM, Jussi Piitulainen wrote: sean.diza...@gmail.com writes: Can someone please explain this to me? Thanks in advance! ~Sean Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 12:39:47) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits"

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Neil Cerutti
On 2017-06-02, Dennis Lee Bieber wrote: > > A bit of a long free-association rambling... > > On Fri, 2 Jun 2017 12:07:45 + (UTC), Neil Cerutti > declaimed the following: >>You're probably not expected to interleave transaction control >>commands from different levels of abstraction, e.g

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Chris Angelico
On Sat, Jun 3, 2017 at 2:45 AM, Jon Ribbens wrote: > On 2017-06-02, Dennis Lee Bieber wrote: >> Connector/Python (MySQL) [guess it is time for me to finally upgrade to >> Python 3.x -- it was the delay in getting mysqldb ported that held me back] >> does allow for turning on autocommit -- w

Very Slow Disk Writes when Writing Large Data Blocks

2017-06-02 Thread remmm
I'm seeing slow write speeds from both Python and C code on some Windows workstations. In particular both Python "write" and numpy "tofile" method suffers from this issue. I'm wondering if anyone has any ideas regarding if this is a known issue, know the cause, or how to resolve the issue? Th

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Skip Montanaro
On Fri, Jun 2, 2017 at 11:14 AM, Dennis Lee Bieber wrote: > My conclusion: > If using a DB-API compliant adapter, explicitly issuing "begin" and > "commit" via .execute() should be avoided if one expects to be portable > (change the adapter from one DBMS to another). > Learn the b

Re: Very Slow Disk Writes when Writing Large Data Blocks

2017-06-02 Thread Irmen de Jong
On 2-6-2017 20:14, remmm wrote: > These write speeds are in the range of 18 to 25 MBytes per second for > spinning disks and about 50 Mbytes/sec for SSDs. Keep in mind these numbers > should be more like 120 MBytes/sec for spinning disks and 300 MBytes/sec for > SSDs. You'll only reach thos

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Jon Ribbens
On 2017-06-02, Chris Angelico wrote: > On Sat, Jun 3, 2017 at 2:45 AM, Jon Ribbens wrote: >> Bewaare - MyISAM tables have no transactions for DML but they do have >> transactions for DDL. Insane but true. > > Not insane; not all DBMSes have transactional DDL, and of the major > ones, several have

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Neil Cerutti
On 2017-06-02, Skip Montanaro wrote: > On Fri, Jun 2, 2017 at 11:14 AM, Dennis Lee Bieber > wrote: > I just checked, and the sqlite3 adapter I have access to > (Python 2.7.13 in a Conda env, module version 2.6.0, SQLite3 > 3.13.0) has no autocommit attribute at all. I checked at the > module, con

CherryPy Session object creation logic

2017-06-02 Thread Israel Brewster
I have a CherryPy app, for which I am using a PostgreSQL session. To be more exact, I modified a MySQL session class I found to work with PostgreSQL instead, and then I put this line in my code: cherrypy.lib.sessions.PostgresqlSession = PostgreSQLSession And this works fine. One thing about its

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Skip Montanaro
On Fri, Jun 2, 2017 at 2:40 PM, Neil Cerutti wrote: > You get autocommit with sqlite3 by setting isolation_level=None > on the connection object. > Thanks for the pointer. I'd probably never have noticed the correspondence. Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Chris Angelico
On Sat, Jun 3, 2017 at 5:31 AM, Jon Ribbens wrote: > On 2017-06-02, Chris Angelico wrote: >> On Sat, Jun 3, 2017 at 2:45 AM, Jon Ribbens >> wrote: >>> Bewaare - MyISAM tables have no transactions for DML but they do have >>> transactions for DDL. Insane but true. >> >> Not insane; not all DBMSe

HD LIVE مسلسل غرابيب سود الحلقة 8 @) ))MBC(( مشاهدة غرابيب سود الحلقة 8 الثامنة كاملة LBC

2017-06-02 Thread 6hktt . com
HD LIVE مسلسل غرابيب سود الحلقة 8 @) ))MBC(( مشاهدة غرابيب سود الحلقة 8 الثامنة كاملة LBCHD LIVE مسلسل غرابيب سود الحلقة 8 @) ))MBC(( مشاهدة غرابيب سود الحلقة 8 الثامنة كاملة LBCHD LIVE مسلسل غرابيب سود الحلقة 8 @) ))MBC(( مشاهدة غرابيب سود الحلقة 8 الثامنة كاملة LBCHD LIVE مسلسل غرابيب سود الحل

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Chris Angelico
On Sat, Jun 3, 2017 at 7:29 AM, Dennis Lee Bieber wrote: > On Sat, 3 Jun 2017 06:48:28 +1000, Chris Angelico > declaimed the following: > >> >>Wait, you have transactions with MyISAM now? I thought MySQL supported >>transactions with InnoDB but not MyISAM, and the reason you didn't get >>transact

Psycopg2 pool clarification

2017-06-02 Thread Israel Brewster
I've been using the psycopg2 pool class for a while now, using code similar to the following: >>> pool=ThreadedConnectionPool(0,5,) >>> conn1=pool.getconn() >>> >>> pool.putconn(conn1) repeat later, or perhaps "simultaneously" in a different thread. and my understanding was that the pool l

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Gregory Ewing
Chris Angelico wrote: Always using a context manager is good practice and great for code clarity. Another thing about my Firebird interface was that you were forced to always use transactions, because the transaction object was the only thing that had methods for executing statements. -- Greg

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Gregory Ewing
Chris Angelico wrote: with psycopg2.connect(...) as conn: with conn.trans() as trn: for row in trn.execute("select ..."): print(row) The outer context manager is optional, but not the inner one While I fully support making the use of transactions mandatory, I wouldn't l

Re: Python DB API - commit() v. execute("commit transaction")?

2017-06-02 Thread Chris Angelico
On Sat, Jun 3, 2017 at 11:46 AM, Gregory Ewing wrote: > Chris Angelico wrote: >> >> with psycopg2.connect(...) as conn: >> with conn.trans() as trn: >> for row in trn.execute("select ..."): >> print(row) >> >> The outer context manager is optional, but not the inner one > >