Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F70137038
dbtest.in
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, Jul 5, 10:52
Size
2 KB
Mime Type
text/x-python
Expires
Sun, Jul 7, 10:52 (2 d)
Engine
blob
Format
Raw Data
Handle
18795959
Attached To
R3600 invenio-infoscience
dbtest.in
View Options
#!@PYTHON@
## -*- mode: python; coding: utf-8; -*-
##
## $Id$
##
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002, 2003, 2004, 2005 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.
## fill config variables:
dbhost = "@DBHOST@"
dbname = "@DBNAME@"
dbuser = "@DBUSER@"
dbpass = "@DBPASS@"
## 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()
Event Timeline
Log In to Comment