Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85139385
dbtest.wml
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Sep 27, 01:21
Size
2 KB
Mime Type
text/x-c
Expires
Sun, Sep 29, 01:21 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21108068
Attached To
R3600 invenio-infoscience
dbtest.wml
View Options
## $Id$
## Tests Python/MySQL connectivity. Called while "make".
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## read config variables:
#include "config.wml"
#include "configbis.wml"
## start Python:
## start Python:
<protect>#!</protect><PYTHON>
<protect>## $Id$</protect>
<protect>## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.</protect>
## fill config variables:
dbhost = "<DBHOST>"
dbname = "<DBNAME>"
dbuser = "<DBUSER>"
dbpass = "<DBPASS>"
## okay, rest of the Python code goes below
#######
<protect>
## import modules:
try:
import MySQLdb
import sys
except ImportError, e:
print "Error: %s" % e
import sys
sys.exit(1)
## try to connect to the DB server:
try:
db = MySQLdb.connect(host=dbhost, db=dbname, user=dbuser, passwd=dbpass)
except MySQLdb.Error, e:
print "Database connectivity error %d: %s" % (e.args[0], e.args[1])
print "Probably you do not have proper MySQL user credentials."
print "You need to fix this error before continuing!"
sys.exit(1)
## execute test query:
try:
cursor = db.cursor()
cursor.execute("SELECT * FROM collection")
row = cursor.fetchone()
except MySQLdb.Error, e:
print """
*************************************************
** DATABASE QUERY ERROR %d: %s.
*************************************************
** Perhaps you need to create CDSware tables? **
** If yes, then run 'make create-tables' now. **
** If not, then read the above error message **
** and fix the problem before continuing! **
*************************************************
""" % (e.args[0], e.args[1])
sys.exit(1)
## close connection:
cursor.close()
db.close()
</protect>
Event Timeline
Log In to Comment