summaryrefslogtreecommitdiff
path: root/Connections/Shear/Finplate/model.py
blob: b1b32f2dcef95d5556b1f3035efcf67941519b72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
'''
Created on 09-Sep-2014

@author: deepa
'''
import sys
from PyQt4 import QtGui,QtCore
from PyQt4.QtSql import *
import logging

# logging.basicConfig(filename = 'finlog.html',filemode = 'w',level = logging.DEBUG)
logger = None

def set_databaseconnection():
    '''
    Setting connection with SQLite
    '''
    filepath = "/home/deepa/Database/Osdag"
    db = QSqlDatabase.addDatabase("QSQLITE")
    db.setDatabaseName(filepath)
    #db.open()
    if not db.open():
        
        QtGui.QMessageBox.critical(None, QtGui.qApp.tr("Cannot open database"),
               QtGui.qApp.tr("Unable to establish a database connection.\n"
                             "This example needs SQLite support. Please read "
                             "the Qt SQL driver documentation for information "
                             "how to build it.\n\n"
                             "Click Cancel to exit."),
               QtGui.QMessageBox.Cancel)
        return False   

    logger.info("feching records from database")
    
# def set_databaseconnection():
#     '''
#     Setting connection with MySQL database
#     '''
#     db = QSqlDatabase.addDatabase("QMYSQL")
#     db.setHostName("localhost")
#     db.setPort(3306)
#     db.setDatabaseName("OSDAG")
#     db.setUserName("root")
#     db.setPassword("root")
#     db.open()
#     logger.info("feching records from database")
    
def module_setup():
    global logger 
    logger = logging.getLogger("osdag.model")
    set_databaseconnection()

def get_beamcombolist():
    '''(None) -> (List)
    This function returns list of Indian Standard Beam Designation.
    '''      
    comboList = []
    beamQuery = QSqlQuery("Select Designation from Beams")
    comboList.append("Select Designation")
    while(beamQuery.next()):
        comboList.append(beamQuery.value(0).toString())
    print "printing comboList"
    print comboList
    return comboList


def get_beamdata(sect):
    '''(None) --> (Dictionary)
    This Function returns the Indian Standard Beam section properties.
    '''
    section  = sect
   
    queryStr = "Select * from Beams where Designation = '%s'" % section
    
    designQuery = QSqlQuery(queryStr)
    print(designQuery)

    print designQuery.size()
    retDict = {}
    record = designQuery.record()
    
    while(designQuery.next()):
        for i in range(0, record.count()):
            colName = record.fieldName(i)
            retDict[colName] = designQuery.value(i).toString()

    #print(retDict[QString("tw")])
    
    return retDict
    
def get_columncombolist():
    '''(None) -> (List)
    This function returns the list of Indian Standard Column Designation.
    '''      
    comboList = []
    columnQuery = QSqlQuery("SELECT Designation FROM Columns")
    comboList.append("Select Column")
    while(columnQuery.next()):
        comboList.append(columnQuery.value(0).toString())
    return comboList

def get_columndata(sect):

    '''(None) --> (Dictionary)
    This Function returns the Indian Standard column section properties.
    '''
    section = sect
    #section = Ui_MainWindow.comboColSec.currentText()
    queryStr = "Select * from Columns where Designation = '%s'" % section
    
    designQuery = QSqlQuery(queryStr)
    print(designQuery)
    
    print designQuery.size()
    retDict = {}
    record = designQuery.record()
    
    while(designQuery.next()):
        for i in range(0, record.count()):
            colName = record.fieldName(i)
            retDict[colName] = designQuery.value(i).toString()
    
    return retDict

module_setup()