def __init__(self, name, table, backref=None, default=None, **kwds): '''a reference column - name: name of this reference - table: the table this reference refers to ''' # length is not a valid input length = kwds.get('length') if length: raise ValueError, "'length' is not a valid keyword for 'Reference'" # self._checkReferredTable(table) Column.__init__(self, name, default, **kwds) # self.referred_table = table if backref: from BackReference import BackReference br = BackReference(self) setattr(table, backref, br) # establish constraint name = table.getTableName() self.constraints = 'REFERENCES %s (id)' % name return
def test2_update_dimension_3(): temp = Query(dbms=dbms, columns=[Column("1","numeric(1)"),Column("'DESCONOCIDO'","varchar()")]) cond = Query( dbms=dbms, sources=[lkp], columns=[Column(dbms.count("TEST_ID"), "numeric(3)")] ) statements = "IF (" + cond.code() + ") = 0 BEGIN\n" statements += lkp.insert( query= temp ) statements += "END\n" statements += lkp.update_scd1( source = table, join_conditions = [["CauBajCod = TEST_ID"]] ) statements += lkp.update_from( columns = [lkp.columns["TEST_DESC"]], source = table, where = [table.columns["CauBajCod"].equals(lkp.columns["TEST_ID"])] ) return statements
def __init__(self, name, **kwds): '''a versatile reference column - name: name of this reference ''' Column.__init__(self, name, **kwds) return
def __init__(self, table, name=None, backref=None, default=None, **kwds): '''a reference column - table: the table this reference refers to - name: name of this reference ''' # length is not a valid input length = kwds.get('length') if length: raise ValueError, "'length' is not a valid keyword for 'Reference'" # we don't want to check for id #self._checkReferredTable(table) if name is None: name = table.__class__.__name__ name = table.__name__ Column.__init__(self, name, default, **kwds) # self.referred_table = table if backref: from BackReference import BackReference br = BackReference(self) setattr(table, backref, br) # establish constraint try: tablename = table.getTableName() except: tablename = table.__class__.__name__ self.constraints = 'REFERENCES %s (id)' % tablename
def _init_column(self): # extract total number of people num = 0 if self.main_table.follower is None else len( self.main_table.follower) # ref column for i in range(2): col = Column(num, column_type[2], role[1], last_row=column_last_row[3]) self.container[attach_column_type[i]] = col # init column self.container[attach_column_type[2]] = Column( num, column_type[2], role[1], last_row=column_last_row[3], number_format=10) self.container[attach_column_type[3]] = Column( num, column_type[1], role[2], last_row=column_last_row[3]) self.container[attach_column_type[4]] = Column( num, column_type[1], role[2], last_row=column_last_row[3], formula_type=formula_type[2]) self.container[attach_column_type[5]] = Column( num, column_type[1], role[2], last_row=column_last_row[3], formula_type=formula_type[2])
def __init__(self, name, tableRegistry, length=1024, **kwds): '''a versatile reference column - name: name of this reference ''' Column.__init__(self, name, **kwds) self.length = length self.tableRegistry = tableRegistry return
def __init__(self, name, tableRegistry, length = 1024, **kwds): '''a versatile reference column - name: name of this reference ''' Column.__init__(self, name, **kwds) self.length = length self.tableRegistry = tableRegistry return
def test_2_update_dimension_2(): column1 = Column('Name', 'Person', 'varchar(20)', False) column2 = Column('Age', 'Person', 'numeric(2)', False) table = Table(sql, 'Person', [column1, column2], [column1.name]) column1 = Column('Person_Name', 'Person', 'varchar(20)', False) column2 = Column('Person_Age', 'Person', 'numeric(2)', False) lkp = SCDimension1(sql, 'Lkp_Person', [column1, column2], [column1.name]) return lkp.update_scd1( table, [[lkp.columns['Person_Name'].equals(table.columns['Name'])]])
def add_col(self, new_col, override=False): """ Adds new column object to DataFrame. """ if type(new_col) == dict: new_col = Column(new_col['colname'], new_col['coltype'], new_col['unit']) if override: # replace column in current DataFrame object with df2 column (if there are overlapping column types) self.remove_col(self.get_column_by_type(new_col.get_coltype())) self.columns.append(new_col) else: # only add column object from df2 if there does not exist a column object in current df of same type if new_col.get_coltype() not in (self.get_col_types()): self.columns.append(new_col)
def __get__(self, instance, cls = None): ret = Column.__get__(self, instance, cls = cls) # class variable request if ret is self: return self return self._cast( ret )
def __get__(self, instance, cls=None): ret = Column.__get__(self, instance, cls=cls) if ret is None: import time return time.ctime() return self._cast(ret)
def _init_req_columns(self, columns): """ Creates column objects for each column required by dataframe type. Throws error if a required column is not found in data. """ new_columns = [] # looping through required columns for col in self.req_columns: ''' try: # getting the variable type of the column unit = self.df[columns[col]['name']].dtype except: # exit if the column isn't found in the data print(col, ' column not found in data.') sys.exit(1) ''' try: # creating new column object new_col = Column(columns[col]['name'], columns[col]['type'], columns[col]['unit']) new_columns.append(new_col) except: print( 'Please ensure you have all required columns in config file.' ) sys.exit(1) return new_columns
def parseLine(line): """ Reads a line and attempts a JSON decode. This function automatically looks for the first instance of an opening bracket '{', and continues until the end of the line. The parsing will respect a given offset, but perhaps that's a bit redundant. @param {name: "line", dataType: "string", comment: "Line of input."} @return """ global args, columnConfig try: result = json.loads( line[line[args.offset:].index('{'):].encode('utf-8')) except ValueError: return [] except UnicodeEncodeError: return [] # You didn't specify any columns if not args.columns: return "No specified columns to print.\n" columnList = [] for column in columnConfig: columnList.append( Column(column["name"], result[column["name"]].encode('utf-8') if column["name"] in result else "", justify=column["justify"], minWidth=column["minWidth"], maxWidth=column["maxWidth"])) return columnList
def __init__(self, name, table, default="", **kwds): '''a reference column - name: name of this reference - table: the table this reference refers to ''' self._checkReferredTable(table) self.length = table.id.length length = kwds.get('length') if length: raise ValueError, "'length' is not a valid keyword for 'Reference'" Column.__init__(self, name, default, **kwds) self.referred_table = table return
def createTable(self): con = sqlite3.connect(self.name + '.db') con.row_factory = sqlite3.Row cur = con.cursor() print('1. CREATE FROM DB STUDIO LEVEL') print('2. CREATE BY SQL QUERY') userChoice = pyip.inputChoice(['1', '2'], ('(1/2)')) if userChoice == '1': tableName = pyip.inputStr('Table name:') # CREATING TABLE OBJECT table = Table(tableName) columnsAmount = pyip.inputInt('Columns amount:') for i in range(columnsAmount): columnName = pyip.inputStr('Column name: ') columnType = pyip.inputStr('Column type: ') # CREATING COLUMN OBJECT column = Column(columnName, columnType) # ADDING COLUMN OBJECT TO THE COLUMNS PROPERTY IN TABLE OBJECT table.columns.append(column) # ADDING TABLE TO THE TABLES PROPERTY IN DATABASE OBJECT self.tables.append(table) # CREATING SQL QUERY query = 'CREATE TABLE ' + table.name + ' (\n' for i in range(len(table.columns)): query += table.columns[i].name + table.columns[i].type + ',\n' # HEREEEE for i in range(len(table.columns)): print(table.columns[i].name, table.columns[i].type, table.columns[i].value)
def convertToTable(self, myNodeObj, columnObj, listObj, length): if columnObj == None: #root node spanning = 0 for node in myNodeObj.getNodeList(): newColumn = Column() listObj.append(newColumn) spanning += self.convertToTable(node, newColumn, listObj, length) return spanning else: #not root node pos = 0 if myNodeObj.getContent() != "null": columnObj.addCell(myNodeObj.getTextElement()) pos = len(columnObj.getCellsList()) if myNodeObj.getTextElement().getColspan() == 1: self.updateColumnValues(columnObj, myNodeObj.getTextElement()) else: textElement = TextElement() columnObj.addCell(textElement) pos = len(columnObj.getCellsList()) if len(myNodeObj.getNodeList()) >= 1: columnClone = columnObj.clone() spanning = 0 spanning += self.convertToTable(myNodeObj.getNodeElement(0), columnObj, listObj, length) for posCounter in range(1, len(myNodeObj.getNodeList())): newColumn = Column() newColumn.setCellsList(columnClone.getCellsList()) listObj.append(newColumn) spanning +=self.convertToTable(myNodeObj.getNodeElement(posCounter),\ newColumn, listObj, length) textElement = columnObj.getCellsListElement(pos-1) textElement.setColspan(spanning) return spanning else: # no children means that we are at the leaf of a branch while len(columnObj.getCellsList()) < length: textElement = TextElement() columnObj.addCell(textElement) return 1
def test_2_update_dimension_1(): column1 = Column('Name', 'Person', 'varchar(20)', False) column2 = Column('Age', 'Person', 'numeric(2)', False) table = Table(tdms, 'Person', [column1, column2], [column1.name]) column1 = Column('Person_Name', 'Person', 'varchar(20)', False) column2 = Column('Person_Age', 'Person', 'numeric(2)', False) lkp = SCDimension1(sql, 'Lkp_Person', [column1, column2], [column1.name]) query = Query(dbms=sql, sources=[table], columns=[table.columns["Name"], table.columns["Age"]], alias='') return lkp.update_scd1( query, [[lkp.columns['Person_Name'].equals(table.columns['Name'])]])
def test_2_update_dimension_1(): column1 = Column('Name', 'varchar(20)', False) column2 = Column('Age', 'numeric(2)', False) table = Table(tdms, 'Person', [column1, column2], [column1.name]) column1 = Column('Person_Name', 'varchar(20)', False) column2 = Column('Person_Age', 'numeric(2)', False) column_valid = Column('Valid_Record', 'numeric(1)', False) column_init_date = Column('Init_Date', 'date', False) column_end_date = Column('End_Date', 'date') lkp = SCDimension2(sql, 'Lkp_Person', [column1, column2], column_valid, column_init_date, column_end_date, [column1.name]) query = Query(dbms=sql, sources=[table], columns=[table.columns["Name"], table.columns["Age"]], alias='') return lkp.update_scd2(source=query, join_conditions=[[ lkp.columns['Person_Name'].equals( query.columns['Name']) ]])
def __get__(self, instance, cls=None): ret = Column.__get__(self, instance, cls=cls) # class variable request if ret is self: return self if not isinstance(ret, reference): ret = self._cast(ret) return ret
def get_columns(self): post_url = self.url + '/posts' r = requests.get(post_url) soup = BeautifulSoup(r.content) for each_column in soup.find_all("a", "avatar-link"): #if not collumnBloom.is_element_exist(each_column['href']): # collumnBloom.insert_element(each_column['href']) from Column import Column yield Column(each_column['href'])
def __get__(self, instance, cls = None): ret = Column.__get__(self, instance, cls = cls) # class variable request if ret is self: return self if not isinstance(ret, reference): ret = self._cast( ret ) return ret
def generate_columns(self): self.columns = [] for i in self.table_definition: self.columns.append( Column(self.cnx, i['COLUMN_NAME'], i['IS_NULLABLE'], i['DATA_TYPE'], i['CHARACTER_MAXIMUM_LENGTH'], i['NUMERIC_PRECISION'], i['NUMERIC_SCALE'], i['COLUMN_TYPE'], i['IS_AUTOINC'], i['IS_UNIQUE'], i['REFERENCED_SCHEMA'], i['REFERENCED_TABLE'], i['REFERENCED_COLUMN'], self.table_name))
def _init_opt_columns(self, columns): """ Creates column objects for all optional columns. """ new_columns = [] # looping through all user defined columns for col in columns: if col not in self.req_columns: unit = self.df[columns[col]['NAME']].dtype if unit == 'O': self.preprocess_opt_columns(columns[col]['NAME']) new_col = Column(columns[col]['NAME'], columns[col]['TYPE'], unit) new_columns.append(new_col) return new_columns
def __init__(self, master=None): Frame.__init__(self, master) self.master = master self.master.title("SportStreamer") self.master.configure(background='slate grey') self.forum = None self.game = None self.Sports = Column(self.master, 'SeaGreen3') self.Games = Column(self.master, 'SkyBlue3') self.Links = Column(self.master, 'forest green') self.make_sport_buttons()
def convertToTable(self, myNodeObj, columnObj, listObj, length): if columnObj == None: #root node spanning = 0 for node in myNodeObj.getNodeList(): newColumn = Column() listObj.append(newColumn) spanning += self.convertToTable(node, newColumn, listObj, length) return spanning else: #not root node pos = 0 if myNodeObj.getContent() != "null": columnObj.addCell(myNodeObj.getTextElement()) pos = len(columnObj.getCellsList()) if myNodeObj.getTextElement().getColspan() == 1: self.updateColumnValues(columnObj, myNodeObj.getTextElement()) else: textElement = TextElement() columnObj.addCell(textElement) pos = len(columnObj.getCellsList()) if len(myNodeObj.getNodeList()) >= 1: columnClone = columnObj.clone() spanning = 0 spanning += self.convertToTable(myNodeObj.getNodeElement(0), columnObj, listObj, length) for posCounter in range(1, len(myNodeObj.getNodeList())): newColumn = Column() newColumn.setCellsList(columnClone.getCellsList()) listObj.append(newColumn) spanning +=self.convertToTable(myNodeObj.getNodeElement(posCounter),\ newColumn, listObj, length) textElement = columnObj.getCellsListElement(pos - 1) textElement.setColspan(spanning) return spanning else: # no children means that we are at the leaf of a branch while len(columnObj.getCellsList()) < length: textElement = TextElement() columnObj.addCell(textElement) return 1
def test_2_update_dimension_2(): column1 = Column('Name', 'Person', 'varchar(20)', False) column2 = Column('Age', 'Person', 'numeric(2)', False) table = Table(sql, 'Person', [column1, column2], [column1.name]) column1 = Column('Person_Name', 'Person', 'varchar(20)', False) column2 = Column('Person_Age', 'Person', 'numeric(2)', False) column_valid = Column('Valid_Record', 'numeric(1)', False) column_init_date = Column('Init_Date', 'date', False) column_end_date = Column('End_Date', 'date') lkp = SCDimension2(sql, 'Lkp_Person', [column1, column2], column_valid, column_init_date, column_end_date, [column1.name]) return lkp.update_scd2(source=table, join_conditions=[[ lkp.columns['Person_Name'].equals( table.columns['Name']) ]])
class TwoCols: thing = 0 nextTime = 0 def __init__(self, app): self.app = app self.col1 = Column(int(self.app.width/3), self.app) self.col2 = Column(int(2*self.app.width/3), self.app) def move(self): self.col1.move() self.col2.move() if self.nextTime == 0: self.nextTime = self.thing + random.randint(50, 300) self.thing += 1 if self.thing % 400 == 0: self.generateNewNotes() self.nextTime = 0 def generateNewNotes(self): if random.randint(1,2) == 1: self.col1.newNote() else: self.col2.newNote()
def __init__(self, name, **kwds): Column.__init__(self, name, **kwds) return
def __init__(self, name, tz=True, **kwds): Column.__init__(self, name, **kwds) self.tz = tz return
def __init__(self, **kwds): Column.__init__(self, **kwds) return
def __init__(self, name=None, length=48, default="", **kwds): if name is None: name = 'str' + str(id(self)) Column.__init__(self, name, default, **kwds) self.length = length
def __init__(self, name, length, **kwds): Column.__init__(self, name, **kwds) self.length = length return
def add_column(self, column_name, column_type): self.columns.append(Column(column_name, column_type))
def declaration(self): default = self.default self.default = None ret = Column.declaration(self) self.default = default return ret
def add_column(self, column_name, column_type, column_equivalences): self.columns.append( Column(column_name, column_type, column_equivalences))
def __get__(self, instance, cls=None): ret = Column.__get__(self, instance, cls = cls) if ret is None: return self._getDefaultValue() return self._cast(ret)
def __init__(self, name, default=0, **kwds): Column.__init__(self, name, default, **kwds) return
def __init__(self, name, shape=None, **kwds): Column.__init__(self, name, **kwds) self.shape = shape return
def __init__(self, name, length, default="", **kwds): Column.__init__(self, name, default, **kwds) self.length = length return