On Sat, 21 Feb 2015 16:22:36 +0100, Peter Otten <__pete...@web.de>
wrote:
>
>Why would you care about a few lines? You don't repeat them, do you? Put the
>code into a function or a context manager and invoke it with
Thanks for the suggestions that followed.
--
https://mail.python.org/mailman/li
On Sun, 22 Feb 2015 13:15:09 -0600, Skip Montanaro
wrote:
>
>Sorry, I haven't paid careful attention to this thread, so perhaps
>this has already been suggested, however... Can't you write your own
>class which delegates to the necessary sqlite3 bits and has a context
>manager with the desired be
On Sun, 22 Feb 2015 19:07:03 +, Mark Lawrence
wrote:
>
>Looks like you're correct. Knock me down with a feather, Clevor Trevor.
It took me by surprise when I first encountered it too. The rationale
apparently is that the context manager is strictly a transactional
feature, allowing for mult
On Sun, Feb 22, 2015 at 12:41 PM, Mario Figueiredo wrote:
> The sqlite context manager doesn't close a database connection on
> exit. It only ensures, commits and rollbacks are performed.
Sorry, I haven't paid careful attention to this thread, so perhaps
this has already been suggested, however..
On 22/02/2015 18:41, Mario Figueiredo wrote:
On Sat, 21 Feb 2015 12:22:58 +, Mark Lawrence
wrote:
Use your context manager at the outer level.
import sqlite3 as lite
try:
with lite.connect('data.db') as db:
try:
db.execute(sql, parms)
except lite.IntegrityError:
On Sat, 21 Feb 2015 12:22:58 +, Mark Lawrence
wrote:
>
>Use your context manager at the outer level.
>
>import sqlite3 as lite
>
>try:
> with lite.connect('data.db') as db:
> try:
> db.execute(sql, parms)
> except lite.IntegrityError:
> raise ValueError('invalid da
Ian Kelly wrote:
> On Sat, Feb 21, 2015 at 8:27 AM, Peter Otten <__pete...@web.de> wrote:
>> Ian Kelly wrote:
>>
>>> On Sat, Feb 21, 2015 at 5:22 AM, Mark Lawrence
>>> wrote:
try:
with lite.connect('data.db') as db:
try:
db.execute(sql, parms)
except l
On Sat, Feb 21, 2015 at 8:27 AM, Peter Otten <__pete...@web.de> wrote:
> Ian Kelly wrote:
>
>> On Sat, Feb 21, 2015 at 5:22 AM, Mark Lawrence
>> wrote:
>>> try:
>>> with lite.connect('data.db') as db:
>>> try:
>>> db.execute(sql, parms)
>>> except lite.IntegrityError:
>>>
Ian Kelly wrote:
> On Sat, Feb 21, 2015 at 5:22 AM, Mark Lawrence
> wrote:
>> On 21/02/2015 02:42, Mario Figueiredo wrote:
>>>
>>> Hello all,
>>>
>>> I'm using the following pattern for db access that requires me to
>>> close the connection as soon as it is not needed:
>>>
>>> import sq
Mario Figueiredo wrote:
> Hello all,
>
> I'm using the following pattern for db access that requires me to
> close the connection as soon as it is not needed:
>
> import sqlite3 as lite
>
> try:
> db = lite.connect('data.db')
> except lite.DatabaseError:
>
On Sat, Feb 21, 2015 at 5:22 AM, Mark Lawrence wrote:
> On 21/02/2015 02:42, Mario Figueiredo wrote:
>>
>> Hello all,
>>
>> I'm using the following pattern for db access that requires me to
>> close the connection as soon as it is not needed:
>>
>> import sqlite3 as lite
>>
>> t
On 21/02/2015 02:42, Mario Figueiredo wrote:
Hello all,
I'm using the following pattern for db access that requires me to
close the connection as soon as it is not needed:
import sqlite3 as lite
try:
db = lite.connect('data.db')
except lite.DatabaseErro
On Fri, Feb 20, 2015 at 6:42 PM, Mario Figueiredo wrote:
> import sqlite3 as lite
>
> try:
> db = lite.connect('data.db')
> except lite.DatabaseError:
> raise OSError('database file corrupt or not found.')
> else:
> try:
>
Hello all,
I'm using the following pattern for db access that requires me to
close the connection as soon as it is not needed:
import sqlite3 as lite
try:
db = lite.connect('data.db')
except lite.DatabaseError:
raise OSError('database file corrupt
14 matches
Mail list logo