473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

MySQL connectivity...

cpiyush
31
Hello,

I have query related to MySQL connectivity.

When we make a connection with MySQL and we don't use this connection for some particular amount of time (I don't know what) it automatically get disconnected. I don't want this thing to happen.

I remember one thing of MySQL that it provides a facility for this that whenever we make any connection with server a periodic acknowledgement singal is transferred between server & connection program, but I dont know how to use it.

Can you please help me out for this???

Thanks.
Apr 3 '07 #1
2 2325
cpiyush
31
Hello,

I have query related to MySQL connectivity.

When we make a connection with MySQL and we don't use this connection for some particular amount of time (I don't know what) it automatically get disconnected. I don't want this thing to happen.

I remember one thing of MySQL that it provides a facility for this that whenever we make any connection with server a periodic acknowledgement singal is transferred between server & connection program, but I dont know how to use it.

Can you please help me out for this???

Thanks.
Hi...

I got the answer...

Its here...


import MySQLdb

def MySqlSample():
""" Python2.4 to MySQL using mysql-python using ping().

"""
# Establish a connection
db=MySQLdb.connection("localhost","root","abcdefgh ","testing")
# Run a MySQL query from Python and get the result set

try:
db.ping()
except ImportError:
pass # No MySQLdb module installed.
except AttributeError:
pass # SQLite connections have not ping() method.
except MySQLdb.OperationalError, e:
if e.args[ 0 ] in ( 2006, 2013 ): # SERVER_GONE or SERVER_LOST error
print 'reconnecting because of', e
db = MySQLdb.connection("localhost","root","","testing" )
db.query("""select dependency from assets where name = 'Java' """)
r = db.store_result()
Apr 11 '07 #2
bartonc
6,596 Expert 4TB
Hi...

I got the answer...

Its here...


import MySQLdb

def MySqlSample():
""" Python2.4 to MySQL using mysql-python using ping().

"""
# Establish a connection
db=MySQLdb.connection("localhost","root","abcdefgh ","testing")
# Run a MySQL query from Python and get the result set

try:
db.ping()
except ImportError:
pass # No MySQLdb module installed.
except AttributeError:
pass # SQLite connections have not ping() method.
except MySQLdb.OperationalError, e:
if e.args[ 0 ] in ( 2006, 2013 ): # SERVER_GONE or SERVER_LOST error
print 'reconnecting because of', e
db = MySQLdb.connection("localhost","root","","testing" )
db.query("""select dependency from assets where name = 'Java' """)
r = db.store_result()
There are many examples of MySQL connectivity in the Python > Code Forum.
You are welcome to check those out and post Python related questions in the Python Forum
Apr 11 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Maru, Mulugeta | last post by:
Is there a turorial on MySQL/Python? VisionTV proudly celebrates 15 years as Canada's multi-faith television network.
1
by: Gaz Oakley | last post by:
Hi, I've looked through the mailing list archives trying to find the best ways of connecting to a MySQL database using Python. From what I've seen, people seem to be using...
5
by: Dfenestr8 | last post by:
Hi. Been told by the admin of my (free!) server that he'd rather I should learn to use mysql if I want to continue writing cgi scripts there. Not even sure exactly what mysql is. Is there a...
20
by: John Wells | last post by:
Yes, I know you've seen the above subject before, so please be gentle with the flamethrowers. I'm preparing to enter a discussion with management at my company regarding going forward as either...
6
by: Jay | last post by:
hi people i am trying to connect to ppstgresql on a debian system using perl . i am getting the following error .can any one please suggest what has to be done install_driver(pg) failed:...
6
by: TonyB | last post by:
I'm running the zip'd version of PHP (PHP 5.1.2 zip package) downloaded from here: http://www.php.net/downloads.php. PHP won't connect with MySQL. >From docs and threads, it seems enabling...
1
by: sweety12345 | last post by:
Hello friends,i am developing a forum . I am using jsp/servlets and MySQL as backend. I am inserting customer data in register form and generating customer id using autoincrementable.how to store the...
2
by: healthsp | last post by:
I have a JSP page where I will be entering data . On clicking the submit button,I want this data to go to the database. I want to do it through XML... Any one please help me how to solve this...
1
by: swethak | last post by:
hi, when i run a java program for to store data and retrive using mysql datatabse i got the following errors.I think in that one of error is due to set the class path.I placed my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.