473,800 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checking if a sqlite connection and/or cursor is still open?

Is there a way to check if a SQLite connection and cursor object are
still open? I took a look at the docs and the DB API but didn't see
anything like this.

Thanks.
Oct 30 '06 #1
2 6308
John Salerno wrote:
Is there a way to check if a SQLite connection and cursor object are
still open? I took a look at the docs and the DB API but didn't see
anything like this.

Thanks.
Well, I might have somewhat solved this problem. Since SQLite allows you
to use execute* methods directly on the connection object (thus no need
to create a cursor object), all I need to do is call connection.clos e()
and this doesn't seem to raise an error even if the connection has
already been closed.

I'm still curious if there's a way to check for an open connection, but
it seems like without the cursor object, the task is much easier.
Oct 30 '06 #2
I am not familiar with SQLite driver, but a typical Pythonic way to
check if you can do something is to just try it, and see what happens.
In more practical terms: try to just use the cursor or the connection
and see if an exception will be raised.

Nick V.

John Salerno wrote:
John Salerno wrote:
Is there a way to check if a SQLite connection and cursor object are
still open? I took a look at the docs and the DB API but didn't see
anything like this.

Thanks.

Well, I might have somewhat solved this problem. Since SQLite allows you
to use execute* methods directly on the connection object (thus no need
to create a cursor object), all I need to do is call connection.clos e()
and this doesn't seem to raise an error even if the connection has
already been closed.

I'm still curious if there's a way to check for an open connection, but
it seems like without the cursor object, the task is much easier.
Oct 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4942
by: bolly | last post by:
Hi, I've been putting Python data into a sqlite3 database as tuples but when I retrieve them they come back as unicode data e.g 'u(1,2,3,4)'.How can I change it back to a tuple so I can use it as a Python native datatype? I have looked in the docs and seen there is a decode/encode method but how do I do this? Hope you can help.
2
3794
by: Christian Stooker | last post by:
Part one: ====== Hi ! I want to use SQLite database like the FireBird database: with big isolation level. What's that meaning ? I have an application that periodically check some input directory,
4
3037
by: coldpizza | last post by:
Hi, I want to run a database query and then display the first 10 records on a web page. Then I want to be able to click the 'Next' link on the page to show the next 10 records, and so on. My question is how to implement paging, i.e. the 'Next/Prev' NN records without reestablishing a database connection every time I click Next/Prev? Is it at all possible with cgi/mod_python?
0
1445
by: smitty1e | last post by:
Disclaimer(s): the author is nobody's pythonista. This could probably be done more elegantly. The driver for the effort is to get PyMacs to work with new-style classes. This rendering stage stands alone, and might be used for other purposes. A subsequent post will show using the resulting file to produce (I think valid) .el trampoline signatures for PyMacs. If nothing else, it shows some python internals in an interesting way.
4
7972
by: mahdaeng | last post by:
I have a little Windows application written in C# with a SQLite back- end. I'm using the System.Data.SQLite provider. One of the features the application provides is a database back-up, which just basically copies the S3DB file to a specified location. See the code below: //------------------------------------------------ System.IO.File.Copy(srcPath, destPath, true); //------------------------------------------------
7
1837
by: nospam | last post by:
Hello I need to go through each line of a CSV file, and extract some fields using a regex. Then, I need to check each retrieved field, and if it looks like "", turn this into NULL so that it's correct SQL. I tried a few things, but still can't it working: ======== #Second field might be empty -"" #"Col1",""
2
3938
by: Joe Goldthwaite | last post by:
I'm confused. (Not a new experience). I've got a web application running under Zope. I use the Wing IDE for testing and debugging. When trying to recreate problems that come up on the web, I wrote some little routines that pull my cookies out of the Firefox cookies.txt file into my code. That way, I'm working with all the same options under Wing that my app uses when running under Zope. That's worked great until I upgraded to Firefox...
0
1404
by: Guilherme Polo | last post by:
On Tue, Jul 1, 2008 at 9:51 PM, Joe Goldthwaite <joe@goldthwaites.comwrote: You need sqlite itself (www.sqlite.org) and bindings, pysqlite 2 (http://oss.itsystementwicklung.de/trac/pysqlite/) or aspw (http://code.google.com/p/apsw/) You are confused, yes. The sqlite3 package that comes with python2.5 is actually pysqlite2, which interfaces with sqlite3. Also, sqlite3 and sqlite2 files format are not compatible.
0
2575
by: Joe Goldthwaite | last post by:
Thanks Guilherme. That helped. I guess I was thinking that pysqlite would automatically come with some version of sqlite. The fact that it doesn't is what was causing me to get the strange results. I downloaded the Windows version of the SQLite3.dll. I didn't know where to put it so I first put it in its own directory and tried to register it. That didn't work so I just moved it to the pysqlite directory in site-packages. That did...
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10275
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.