On 24/08/2023 06.11, dn via Python-list wrote:
On 24/08/2023 03.41, Jason Friedman via Python-list wrote:
with Database() as mydb:
conn = mydb.get_connection()
cursor = conn.get_cursor()
cursor.execute("update table1 set x = 1 where y = 2")
cursor.close()
cursor = conn.get_cursor()
cursor.execut
On 24/08/2023 03.41, Jason Friedman via Python-list wrote:
I want to be able to write code like this:
with Database() as mydb:
conn = mydb.get_connection()
cursor = conn.get_cursor()
cursor.execute("update table1 set x = 1 where y = 2")
cursor.close()
cursor = conn.get_cursor()
cursor.execute("u
I want to be able to write code like this:
with Database() as mydb:
conn = mydb.get_connection()
cursor = conn.get_cursor()
cursor.execute("update table1 set x = 1 where y = 2")
cursor.close()
cursor = conn.get_cursor()
cursor.execute("update table2 set a = 1 where b = 2")
cursor.close()
I'd like
On 01/06/2023 06.45, Thomas Passin wrote:
On 5/31/2023 2:10 PM, Jason Friedman wrote:
I'm trying to reconcile two best practices which seem to conflict.
1) Use a _with_ clause when connecting to a database so the connection is
closed in case of premature exit.
class_name = 'oracle.jdbc.OracleD
On 5/31/2023 2:10 PM, Jason Friedman wrote:
I'm trying to reconcile two best practices which seem to conflict.
1) Use a _with_ clause when connecting to a database so the connection is
closed in case of premature exit.
class_name = 'oracle.jdbc.OracleDriver'
url = f"jdbc:oracle:thin:@//{host_na
I'm trying to reconcile two best practices which seem to conflict.
1) Use a _with_ clause when connecting to a database so the connection is
closed in case of premature exit.
class_name = 'oracle.jdbc.OracleDriver'
url = f"jdbc:oracle:thin:@//{host_name}:{port_number}/{database_name}"
with jdbc.c
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 su
grityError:
raise ValueError('invalid data')
except lite.DatabaseError:
raise OSError('database file corrupt or not found.')
The sqlite context manager doesn't close a database connection on
exit. It only ensures, commits and rollbacks are performed.
Where
ror:
> raise ValueError('invalid data')
>except lite.DatabaseError:
> raise OSError('database file corrupt or not found.')
The sqlite context manager doesn't close a database connection on
exit. It only ensures, commits and rollbacks are performed.
--
https://mail.python.org/mailman/listinfo/python-list
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
En Fri, 07 Oct 2011 02:18:04 -0300, masood shaik
escribió:
can u please tell me how we can connect to database without changing
the permission of db file using sqlite3
The OS user who executes the Python script must have read (and write,
usually) access to the database file - *any* OS us
Hi
can u please tell me how we can connect to database without changing
the permission of db file using sqlite3
--
http://mail.python.org/mailman/listinfo/python-list
On Mon, 30 Mar 2009 13:30:18 +0530
bijoy wrote:
> conn=pg.connect("secondbooks.db")
> pg.InternalError: FATAL: database "secondbooks.db" does not exist
> In fact i have a database called secondboo
hi,
I figured out these too.
Pls excuse me
Thanks
Bijoy
On Mon, Mar 30, 2009 at 1:30 PM, bijoy wrote:
> Hi,
>
> *code:* (only the class definiton and Database connection part)
>
> import pg
>
> __metaclass__=type
>
> class addbook:
>
>
Hi,
*code:* (only the class definiton and Database connection part)
import pg
__metaclass__=type
class addbook:
conn=pg.connect('secondbooks.db')
curs=conn.cursor()
*error:*
conn=pg.connect("secondbooks.db")
pg.InternalError: FATAL: database "secon
On Sep 19, 4:03 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> exhuma.twn wrote:
> > On Sep 19, 3:45 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> >> exhuma.twn wrote:
> > [...]
>
> >> By the way, there is a pythonic (near) singleton: the module. So if you go
> >> with option 2, just move the connecti
exhuma.twn wrote:
> On Sep 19, 3:45 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
>> exhuma.twn wrote:
> [...]
>>
>> By the way, there is a pythonic (near) singleton: the module. So if you go
>> with option 2, just move the connection setup into a separate module that
>> you can import into client co
On Sep 19, 3:45 pm, Peter Otten <[EMAIL PROTECTED]> wrote:
> exhuma.twn wrote:
[...]
>
> By the way, there is a pythonic (near) singleton: the module. So if you go
> with option 2, just move the connection setup into a separate module that
> you can import into client code.
>
> Peter
You say "(nea
exhuma.twn wrote:
> I remember reading about the Singleton pattern in python and how it's
> an unpythonic pattern and all. At the time I did not need the
> Singleton anyways, so I just glanced over the document.
>
> But, setting this aside: I have an application where I have a
> connection to a d
On Sep 19, 7:26 am, "exhuma.twn" <[EMAIL PROTECTED]> wrote:
> I remember reading about the Singleton pattern in python and how it's
> an unpythonic pattern and all. At the time I did not need the
> Singleton anyways, so I just glanced over the document.
>
> But, setting this aside: I have an applic
I remember reading about the Singleton pattern in python and how it's
an unpythonic pattern and all. At the time I did not need the
Singleton anyways, so I just glanced over the document.
But, setting this aside: I have an application where I have a
connection to a database. At some point in the a
On Mar 5, 4:44 am, Tim Golden <[EMAIL PROTECTED]> wrote:
> Hitesh wrote:
> > Hi currently I am using DNS and ODBC to connect to MS SQL database.
> > Is there any other non-dns way to connect? If I want to run my script
> > from different server I first have to create the DNS in win2k3.
>
> Here a
Hitesh wrote:
> Hi currently I am using DNS and ODBC to connect to MS SQL database.
> Is there any other non-dns way to connect? If I want to run my script
> from different server I first have to create the DNS in win2k3.
Here are several ways to connect to an MSSQL database w/o
having to create
Hi currently I am using DNS and ODBC to connect to MS SQL database.
Is there any other non-dns way to connect? If I want to run my script
from different server I first have to create the DNS in win2k3.
Thank you,
hj
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> I'm developing an application using the C language and Python for it's
> plugins. The C program connects to a MySQL database and keeps that
> connection active. Is it possible to 'share' this connection with the
> Python plugins? If so, is there a "standard" way to do tha
Hi,
I'm developing an application using the C language and Python for it's
plugins. The C program connects to a MySQL database and keeps that
connection active. Is it possible to 'share' this connection with the
Python plugins? If so, is there a "standard" way to do that?
Thank you.
DG
--
http
On 6/9/05 08:52, Alex Le Dain wrote:
> What is the best way to access a Pervasive database on another machine?
Assuming you mean the Pervasive.SQL DBMS...
...depends what you're trying to do and what you're comfortable with.
Pervasive can be accessed through various access methods, e.g. low-leve
http://www.pervasive.com/developerzone/access_methods/oledbado.asp
--
http://mail.python.org/mailman/listinfo/python-list
Alex Le Dain wrote:
> What is the best way to access a Pervasive database on another machine?
Hi Alex,
You can use ODBC / ADO to access Pervasive DBs. I found this page helpful:
http://www.mayukhbose.com/python/ado/index.php
-Dave
--
http://mail.python.org/mailman/listinfo/python-list
Use the pervasive client. You'll need the SDK to actually access any
data though.
--
http://mail.python.org/mailman/listinfo/python-list
Alex Le Dain wrote, in entirety:
> What is the best way to access a Pervasive database on another machine?
The best way, is, well ... Pervasively!
Sorry. I can be kida a jerk like that.
People often do get get hundreds, sometimes thousands of dollars worth
of consultation from these groups, for
What is the best way to access a Pervasive database on another machine?
cheers, Alex.
--
http://mail.python.org/mailman/listinfo/python-list
Thanks everybody for their replies.
Lorenzo
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
Hi all,
is there an alternative way of:
- create a connection object
- open the connection
- close the connection
psycopg, a Postgresql database adapter does connection pooling
automatically
http://initd.org/projects/psycopg1
Most Zope database adapters also have implicit
c
On 18 Mar 2005 04:52:03 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> is there an alternative way of:
>
> - create a connection object
> - open the connection
> - close the connection
>
> every time one has to run a query.
It's actually morte like:
create connection
create cursor
execut
Lorenzo> is there an alternative way of:
Lorenzo> - create a connection object
Lorenzo> - open the connection
Lorenzo> - close the connection
Lorenzo> every time one has to run a query.
Sure, create a Queue.Queue object and stuff a number of connections into
it. When you wan
On 18 Mar 2005 04:52:03 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> Hi all,
>
> is there an alternative way of:
>
> - create a connection object
> - open the connection
> - close the connection
>
> every time one has to run a query.
Why not use cursor objects with a single connection
Hi all,
is there an alternative way of:
- create a connection object
- open the connection
- close the connection
every time one has to run a query.
I assume that big sites do something to prevent the performance hit
given by these operations, don't they?
Would you kindly point me to some exam
48 matches
Mail list logo