Commit 430193dd authored by panos's avatar panos

Bugs fixed in these scripts

parent aaa22fc4
...@@ -24,7 +24,7 @@ Created on 20 March 2015 ...@@ -24,7 +24,7 @@ Created on 20 March 2015
import Tkinter as tk import Tkinter as tk
from Tkinter import * from Tkinter import *
import ImportDatabase from dream.KnowledgeExtraction.ImportDatabase import ConnectionData
import tkMessageBox import tkMessageBox
from datetime import datetime from datetime import datetime
...@@ -120,7 +120,7 @@ class Demo1(Frame): ...@@ -120,7 +120,7 @@ class Demo1(Frame):
return return
def checkInsertedProject(self): def checkInsertedProject(self):
cnxn=ImportDatabase.ConnectionData(seekName='ServerData', file_path='C:\Users\Panos\Documents\DB_Approach\CapacityStations', implicitExt='txt', number_of_cursors=6) cnxn=ConnectionData(seekName='ServerData', file_path='C:\Users\Panos\Documents\DB_Approach\CapacityStations', implicitExt='txt', number_of_cursors=6)
cursor=cnxn.getCursors() cursor=cnxn.getCursors()
a=cursor[0].execute(""" a=cursor[0].execute("""
...@@ -138,7 +138,7 @@ class Demo1(Frame): ...@@ -138,7 +138,7 @@ class Demo1(Frame):
return availableProject return availableProject
def alreadyInsertedWP(self): def alreadyInsertedWP(self):
cnxn=ImportDatabase.ConnectionData(seekName='ServerData', file_path='C:\Users\Panos\Documents\DB_Approach\CapacityStations', implicitExt='txt', number_of_cursors=6) cnxn=ConnectionData(seekName='ServerData', file_path='C:\Users\Panos\Documents\DB_Approach\CapacityStations', implicitExt='txt', number_of_cursors=6)
cursor=cnxn.getCursors() cursor=cnxn.getCursors()
c=cursor[0].execute(""" c=cursor[0].execute("""
...@@ -156,7 +156,7 @@ class Demo1(Frame): ...@@ -156,7 +156,7 @@ class Demo1(Frame):
def updateDatabase(self): def updateDatabase(self):
cnxn=ImportDatabase.ConnectionData(seekName='ServerData', file_path='C:\Users\Panos\Documents\DB_Approach\CapacityStations', implicitExt='txt', number_of_cursors=13) cnxn=ConnectionData(seekName='ServerData', file_path='C:\Users\Panos\Documents\DB_Approach\CapacityStations', implicitExt='txt', number_of_cursors=13)
cursor=cnxn.getCursors() cursor=cnxn.getCursors()
if self.checkBoxVal2.get(): if self.checkBoxVal2.get():
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
import xlrd import xlrd
import datetime import datetime
import os import os
import ImportDatabase from dream.KnowledgeExtraction.ImportDatabase import ConnectionData
#Static variables that hold the column's number in Workplan (Excel document - template) #Static variables that hold the column's number in Workplan (Excel document - template)
WPColumn=11 WPColumn=11
OrderColumn=0 OrderColumn=0
...@@ -72,7 +72,7 @@ os.chdir(folder_path) ...@@ -72,7 +72,7 @@ os.chdir(folder_path)
#create a list that hold the already inserted orders #create a list that hold the already inserted orders
alreadyInserted=[] alreadyInserted=[]
#use of the KE tool object to connect to database #use of the KE tool object to connect to database
cnxn=ImportDatabase.ConnectionData(seekName='ServerData', implicitExt='txt', number_of_cursors=6) cnxn=ConnectionData(seekName='ServerData', implicitExt='txt', number_of_cursors=6)
cursor=cnxn.getCursors() cursor=cnxn.getCursors()
#loop that searches the files in the given directory #loop that searches the files in the given directory
for fileName in os.listdir("."): for fileName in os.listdir("."):
...@@ -118,7 +118,7 @@ for fileName in os.listdir("."): ...@@ -118,7 +118,7 @@ for fileName in os.listdir("."):
else: else:
#follows the logic of the if part #follows the logic of the if part
check_order= cursor[3].execute(""" check_order= cursor[0].execute("""
select Order_id, ProjectName, Customer, Order_date, Due_date,FloorSpaceRequired select Order_id, ProjectName, Customer, Order_date, Due_date,FloorSpaceRequired
from orders from orders
""") """)
...@@ -127,30 +127,30 @@ for fileName in os.listdir("."): ...@@ -127,30 +127,30 @@ for fileName in os.listdir("."):
ind1=check_order.fetchone() ind1=check_order.fetchone()
dataExtraction(fileName) dataExtraction(fileName)
for i in range(4,Main.nrows): for i in range(4,Main.nrows):
orderId=Main.cell(4,OrderColumn).value orderId=Main.cell(4,OrderColumn).value
projectName=Main.cell(4,ProjectColumn).value projectName=Main.cell(4,ProjectColumn).value
#check the existence of orderId #check the existence of orderId
if not orderId in ind1.Order_id: if not orderId in ind1.Order_id:
add_order= ("INSERT INTO orders(`id`, `Order_id`, `ProjectName`, `Customer`, `Order_date`, `Due_date`, `FloorSpaceRequired`, `Status`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)") add_order= ("INSERT INTO orders(`id`, `Order_id`, `ProjectName`, `Customer`, `Order_date`, `Due_date`, `FloorSpaceRequired`, `Status`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")
cursor[3].execute("SELECT MAX(id)+1 AS ID from orders") cursor[2].execute("SELECT MAX(id)+1 AS ID from orders")
row = cursor[3].fetchone() row = cursor[2].fetchone()
order_ref = row.ID order_ref = row.ID
status= 'accepted' status= 'accepted'
cursor[3].execute(add_order, (order_ref, orderId, projectName, workplan[orderId][projectName][0], workplan[orderId][projectName][1], workplan[orderId][projectName][2], workplan[orderId][projectName][3], status)) cursor[2].execute(add_order, (order_ref, orderId, projectName, workplan[orderId][projectName][0], workplan[orderId][projectName][1], workplan[orderId][projectName][2], workplan[orderId][projectName][3], status))
cursor[3].commit() cursor[2].commit()
add_sequence= ("INSERT INTO sequence(`seq_id`, `WP_id`, `Order_id`, `PartCode`, `PartName`, `Operation_Name`, `CapacityRequirement`, `EarliestStart`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ") add_sequence= ("INSERT INTO sequence(`seq_id`, `WP_id`, `Order_id`, `PartCode`, `PartName`, `Operation_Name`, `CapacityRequirement`, `EarliestStart`) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ")
cursor[4].execute("SELECT MAX(seq_id)+1 AS ID from sequence") cursor[5].execute("SELECT MAX(seq_id)+1 AS ID from sequence")
row = cursor[4].fetchone() row = cursor[5].fetchone()
seq_ref = row.ID seq_ref = row.ID
for i in range(4,Main.nrows): for i in range(4,Main.nrows):
wpId=Main.cell(i,WPColumn).value wpId=Main.cell(i,WPColumn).value
cursor[4].execute(add_sequence, (seq_ref, wpId, orderId, workplan[orderId][wpId][0], workplan[orderId][wpId][1], workplan[orderId][wpId][2], workplan[orderId][wpId][3], workplan[orderId][wpId][4])) cursor[5].execute(add_sequence, (seq_ref, wpId, orderId, workplan[orderId][wpId][0], workplan[orderId][wpId][1], workplan[orderId][wpId][2], workplan[orderId][wpId][3], workplan[orderId][wpId][4]))
cursor[4].commit() cursor[5].commit()
seq_ref+=1 seq_ref+=1
else: else:
continue continue
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment