2010-07-08 20:01:03 +02:00
|
|
|
#!/usr/bin/python
|
2010-07-04 03:05:16 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2008-10-07 08:11:48 +02:00
|
|
|
|
2010-07-04 03:05:16 +02:00
|
|
|
#Copyright 2008-2010 Steffen Schaumburg
|
2008-10-07 08:11:48 +02:00
|
|
|
#This program is free software: you can redistribute it and/or modify
|
|
|
|
#it under the terms of the GNU Affero General Public License as published by
|
|
|
|
#the Free Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
#This program 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 Affero General Public License
|
|
|
|
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-07-04 03:05:16 +02:00
|
|
|
#In the "official" distribution you can find the license in agpl-3.0.txt.
|
2008-10-07 08:11:48 +02:00
|
|
|
|
|
|
|
############################################################################
|
|
|
|
#
|
|
|
|
# File for DB queries used in fpdb
|
|
|
|
#
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
class FpdbSQLQueries:
|
|
|
|
|
2008-12-07 18:23:38 +01:00
|
|
|
def __init__(self, db):
|
|
|
|
self.query = {}
|
|
|
|
self.dbname = db
|
|
|
|
|
2009-07-14 01:04:10 +02:00
|
|
|
|
|
|
|
if(self.dbname == 'MySQL InnoDB' or self.dbname == 'PostgreSQL'):
|
|
|
|
self.query['set tx level'] = """SET SESSION TRANSACTION
|
|
|
|
ISOLATION LEVEL READ COMMITTED"""
|
|
|
|
elif(self.dbname == 'SQLite'):
|
|
|
|
self.query['set tx level'] = """ """
|
|
|
|
|
2008-12-13 02:32:44 +01:00
|
|
|
|
2008-12-19 08:52:32 +01:00
|
|
|
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL'):
|
|
|
|
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
|
|
|
|
elif(self.dbname == 'SQLite'):
|
|
|
|
self.query['getSiteId'] = """SELECT id from Sites where name = %s"""
|
|
|
|
|
2009-04-11 11:10:00 +02:00
|
|
|
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL') or (self.dbname == 'SQLite'):
|
|
|
|
self.query['getGames'] = """SELECT DISTINCT category from Gametypes"""
|
|
|
|
|
|
|
|
if(self.dbname == 'MySQL InnoDB') or (self.dbname == 'PostgreSQL') or (self.dbname == 'SQLite'):
|
|
|
|
self.query['getLimits'] = """SELECT DISTINCT bigBlind from Gametypes ORDER by bigBlind DESC"""
|
|
|
|
|
2009-03-09 16:34:07 +01:00
|
|
|
|
2008-10-07 08:11:48 +02:00
|
|
|
if __name__== "__main__":
|
|
|
|
from optparse import OptionParser
|
|
|
|
|
|
|
|
print "FpdbSQLQueries starting from CLI"
|
|
|
|
|
|
|
|
#process CLI parameters
|
|
|
|
usage = "usage: %prog [options]"
|
|
|
|
parser = OptionParser()
|
|
|
|
parser.add_option("-t", "--type", dest="dbtype", help="Available 'MySQL InnoDB', 'PostgreSQL', 'SQLite'(default: MySQL InnoDB)", default="MySQL InnoDB")
|
|
|
|
parser.add_option("-s", "--show", action="store_true", dest="showsql", help="Show full SQL output")
|
|
|
|
parser.add_option("-v", "--verbose", action="store_true", dest="verbose")
|
|
|
|
|
|
|
|
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
if options.verbose:
|
|
|
|
print """No additional output available in this file"""
|
|
|
|
|
|
|
|
obj = FpdbSQLQueries(options.dbtype)
|
|
|
|
|
|
|
|
print "Available Queries for '" + options.dbtype + "':"
|
|
|
|
|
|
|
|
for key in obj.query:
|
|
|
|
print " " + key
|
|
|
|
if options.showsql:
|
|
|
|
print obj.query[key]
|