def create_stock_base(): tbName = 'stock' paramsDic = {'id': 'INT AUTO_INCREMENT PRIMARY KEY', 'stockCode': 'varchar(32) not null', 'stockName': 'varchar(64) not null'} try: createTable(tbName, paramsDic) print 'Success:' % tbName except Exception, e: print 'Error: %s' % tbName + e.message
def OAUTH_USERID(token): url = "https://api.github.com/user" oauthresponse = requestUser(url, token) userId = oauthresponse['login'] strrrrUserId = db.getUser(userId) if strrrrUserId == 0: print("no id!!! making a new one") db.setToken(userId, token) db.createTable(userId) else: pass return userId
def gm_update(): sql = "create table if not exists gm_update(" \ "id int auto_increment PRIMARY key not null," \ "filename varchar(50) not null comment '更新文件名'," \ "update_time varchar(30) not null comment '更新时间'," \ "status varchar(10) not null comment '更新状态'," \ "username varchar(20) not null comment '更新操作人') " \ "ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=utf8 COMMENT='GM更新说明表'" try: db.get_one(['id'], 'id = "1"', 'gm_update', list=True) except BaseException, e: print e db.createTable(sql)
def code_release(): sql = "create table if not exists codePublish(" \ "id int auto_increment PRIMARY key not null," \ "version int(10) not null comment '代码版本号'," \ "introduction varchar(100) not null comment '发布说明'," \ "username varchar(20) not null comment '发布人'," \ "date varchar(30) not null comment '发布日期') " \ "ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=utf8 COMMENT='代码发布版本说明'" try: db.get_one(['id'], 'id = "1"', 'codePublish', list=True) except BaseException, e: print e db.createTable(sql)
def inner(): sql = "create table if not exists innerServer(" \ "id int auto_increment PRIMARY key not null," \ "hostname varchar(50) not null COMMENT 'hostname'," \ "ip varchar(50) not null COMMENT 'ip'," \ "cpu varchar(20) not null COMMENT 'cpu'," \ "mem varchar(30) not null COMMENT '内存'," \ "disk varchar(30) not null COMMENT '硬盘'," \ "physicalHost varchar(30) COMMENT '宿主机'," \ "user varchar(30) not null COMMENT '使用人') " \ "ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=utf8 COMMENT='内网服务器管理表'" db.createTable(sql) columns = ['id', 'hostname', 'ip', 'cpu', 'mem', 'disk', 'physicalHost', 'user'] data = db.get_list(columns, 'innerServer') return render_template('assets/inner/inner.html', inners=data, display = dis)
def inner(): sql = "create table if not exists innerServer(" \ "id int auto_increment PRIMARY key not null," \ "hostname varchar(50) not null COMMENT 'hostname'," \ "ip varchar(50) not null COMMENT 'ip'," \ "cpu varchar(20) not null COMMENT 'cpu'," \ "mem varchar(30) not null COMMENT '内存'," \ "disk varchar(30) not null COMMENT '硬盘'," \ "physicalHost varchar(30) COMMENT '宿主机'," \ "user varchar(30) not null COMMENT '使用人') " \ "ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=utf8 COMMENT='内网服务器管理表'" db.createTable(sql) columns = [ 'id', 'hostname', 'ip', 'cpu', 'mem', 'disk', 'physicalHost', 'user' ] data = db.get_list(columns, 'innerServer') return render_template('assets/inner/inner.html', inners=data, display=dis)
def run(fileName): if fileName is not None: db.load(fileName) else: db.connect(':memory:') db.createTable() while not quitRequested: try: line = input('> ') if line == '': continue cmd = line.split() cmds[cmd[0]][0](cmd) except KeyError: print(f'{cmd[0]:} is not a command') except Exception as e: print(f"{cmd[0]} command failed with '{e:}'") db.close()
def firstUserAddOpenTheProgram(self): userUsername = self.email.text() userEmail = self.username.text() userPassword = self.password.text() userPasswordConfirm = self.passwordConfirm.text() if userEmail != None and userUsername != None and userPassword != None: if userPassword == userPasswordConfirm: db.createTable() db.createUser(db.genereteID(), userUsername, userEmail, userPassword, True, "") msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText("Cheese :)") msg.setWindowTitle("Cheese :)") msg.exec_() if msg.exec_() == 1024: faceDataSet.saveFaceFrame(1) faceTraining.training() self.window = QtWidgets.QMainWindow() self.ui = Ui_Pathronus() self.ui.PathronusUi(self.window) self.window.show() FirstOpeninWindow.close() else: msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setText("Parolalar Eşleşmedi") msg.setInformativeText('Lütfen Uyuşan Parolalar giriniz') msg.setWindowTitle("Parolalar Eşleşmedi") msg.exec_() else: msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setText("Hiç Bir Alan Boş Bırakılamaz") msg.setWindowTitle("Kritik Hata") msg.exec_()
def create_stock_compare(tbName='stock_compare'): paramsDic = { 'date': 'VARCHAR(16)', 'high': 'INT', 'close': 'INT', 'low': 'INT', 'volume': 'INT', 'ma5': 'INT', 'ma10': 'INT', 'ma20': 'INT', 'v_ma5': 'INT', 'v_ma10': 'INT', 'v_ma20': 'INT', 'turnover': 'INT', 'p_change': 'VARCHAR(4)'} try: createTable(tbName, paramsDic) print 'Success: %s ' % tbName except Exception, e: print 'Error: %s, cause: %s' % (tbName, e.message)
def create_res_tushare(tbName='stock_data'): paramsDic = { 'date': 'VARCHAR(16)', 'open': 'DOUBLE', 'high': 'DOUBLE', 'close': 'DOUBLE', 'low': 'DOUBLE', 'volume': 'DOUBLE', 'price_change': 'DOUBLE', 'p_change': 'DOUBLE', 'ma5': 'DOUBLE', 'ma10': 'DOUBLE', 'ma20': 'DOUBLE', 'v_ma5': 'DOUBLE', 'v_ma10': 'DOUBLE', 'v_ma20': 'DOUBLE', 'turnover': 'DOUBLE'} try: createTable(tbName, paramsDic) print 'Success: %s ' % tbName except Exception, e: print 'Error: %s, cause: %s' % (tbName, e.message)
if p.getHandVal() > d.getHandVal(): #player wins print("Player wins") p.result = 'win' d.result = 'loss' elif p.getHandVal() < d.getHandVal(): #dealer wins print("dealer wins") p.result = 'loss' d.result = 'win' else: #TIE print("Tie") p.result = 'tie' d.result = 'tie' if __name__ == '__main__': db.createTable() iteration = 0 while iteration < 100: gameReset() initializeGame() playerAndDealerTurn() checkWinner(playerOne, dealer) checkWinner(playerAlt, dealerAlt) db.insertData(iteration + 1, playerOne.result, playerAlt.result, dealer.result, dealerAlt.result) iteration += 1 db.graphWins()
def main(): root = tk.Tk() #intialize GUI root db.createTable() app = MainWindow.MainWindow() #create main window root.mainloop()
import datetime import db import parsec dbc = db.dbConnect('localhost', 'root', 'atlas', 'parsec') cursor = db.getCursor(dbc) db.createTable(cursor, 'reports') db.createTable(cursor, 'companies') print '' print '' print '********** PARSEC **********' print '****************************' print '' valid = 0 total = 0 info = {} info['start'] = datetime.datetime.now() completed = db.countReports(dbc, cursor) print str(completed['count']) + ' Existing Reports' print '' for year in range(2016, 1994, -1): for qtr in range(4, 0, -1): index = parsec.getIndex(year, qtr) for report in index:
def createTable_popup(self): table, ok = QInputDialog.getText(self, "Enter Table To Create", "Table To Create:") if ok and table: db.createTable(table)
import os import understand from db import insert from db import createTable createTable() def gf(function): functionList = [] funcList = function.ents("", "function,method,procedure") if funcList == None: return False for function in funcList: if function.library() == "Standard": continue if function.name() != function.name(): functionList.append(function.name()) return functionList def isdependent(func2, func1Related): if func2.name() not in func1Related: return False else:
from boto3.dynamodb.conditions import Key from flask import Flask, request, jsonify, redirect from flask_cors import CORS from db import getTable, hasTable, createTable from utils import validateUrl SERVER_DNS = os.getenv('SERVER_DNS', 'http://*****:*****@application.route('/shorten_url', methods=['POST']) def shortenUrl(): body = request.get_json() if not validateUrl(body['url']): res = {'message': 'Invalid url in request body'} return jsonify(res), 400 hashObject = hashlib.md5(body['url'].encode()) urlHash = hashObject.hexdigest() if 'truncate' in body: