コード例 #1
0
 def __init__(self):
     dbc = DBConnection()
     #create a text file to export calculated results 
     file = open("../Texts/open_closed_results.txt", "w")
     
     print "------------"
     file.write("Closed posts:\n")
     results = dbc.get_closed_posts_stats()
     for result in results:
         file.write(str(result) + "\n")
     print "###---------"
     file.write("\nOpen posts: \n")
     results = dbc.get_open_posts_stats()
     for result in results:
         file.write(str(result) + "\n")
     print "######------"  
     file.write("\n\nNot accepted posts:\n")
     results = dbc.get_not_accepted_posts_stats()
     for result in results:
         file.write(str(result) + "\n")
     print "#########---"
     file.write("\nAccepted posts: \n")
     results = dbc.get_accepted_posts_stats()
     for result in results:
         file.write(str(result)+"\n")
     print "############"   
コード例 #2
0
    def __init__(self):
        self.debug = False
        self.dbc = DBConnection()

        # creates the two tables that hold the differences from one version to another
        #self.dbc.create_evolution_tables()

        # calculates and writes the evolutionary steps of the
        # post blocks into postblockevolution
        self.postblock_evolution()
コード例 #3
0
def UpdateBuildTable(db_name):
                curs = DBConnection(db_name).curs
		for k in BuildConfig.config.keys():
		  query = "SELECT * from build where build_name='%s';" % k;
		  #print query
		  result = curs.execute(query)
		  if result != 0:
		    v = BuildConfig.config[k]
		    query = "UPDATE build set hostname='%s', os='%s', 64bit=%d, compiler='%s', debug=%d, optimized=%d, static=%d, minimum=%d where build_name='%s';" % (v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7], k)
                    #print query
		    curs.execute(query)
コード例 #4
0
def my_scheduled_job():
    date = date.today()
    todaydate = date.strftime("%d-%m-%Y")
    response = requests.get('https://mindicador.cl/api/dolar/'+todaydate)
    time.sleep(20)
    dolardata = response.json()
    if dolardata['serie']:
        date = dolardata['serie'][0]['fecha'][0:10]
        value = dolardata['serie'][0]['valor']
        print(date)
        print(value)
        DBConnection(date, value)
コード例 #5
0
def CreateTables(db_name):
    curs = DBConnection(db_name).curs
    query = "CREATE TABLE IF NOT EXISTS build(build_id SMALLINT NOT NULL AUTO_INCREMENT, build_name VARCHAR(100) NOT NULL, hostname VARCHAR(50), os VARCHAR(20), 64bit TINYINT(1), compiler VARCHAR(20), debug TINYINT(1), optimized TINYINT(1), static TINYINT(1), minimum TINYINT(1), PRIMARY KEY(build_id));"
    curs.execute(query)
    query = "CREATE TABLE IF NOT EXISTS build_instance(build_instance_id INT NOT NULL AUTO_INCREMENT, build_id SMALLINT NOT NULL, start_time DATETIME, end_time DATETIME, baseline VARCHAR(20), log_fname VARCHAR(200), test_insert_time DATETIME, compilation_insert_time DATETIME, PRIMARY KEY(build_instance_id));"
    curs.execute(query)
    query = "CREATE TABLE IF NOT EXISTS test(test_id SMALLINT NOT NULL AUTO_INCREMENT, test_name VARCHAR(100) NOT NULL, PRIMARY KEY(test_id));"
    curs.execute(query)
    query = "CREATE TABLE IF NOT EXISTS test_instance(test_id SMALLINT NOT NULL, build_instance_id INT NOT NULL, status VARCHAR(1), duration_time INT, PRIMARY KEY(test_id, build_instance_id));"
    curs.execute(query)
    query = "CREATE TABLE IF NOT EXISTS project(project_id SMALLINT NOT NULL AUTO_INCREMENT, project_name VARCHAR(100) NOT NULL, PRIMARY KEY(project_id));"
    curs.execute(query)
    query = "CREATE TABLE IF NOT EXISTS compilation_instance(project_id SMALLINT NOT NULL, build_instance_id INT NOT NULL, skipped TINYINT(1), num_errors INT, num_warnings INT, PRIMARY KEY(project_id, build_instance_id));"
    curs.execute(query)
コード例 #6
0
def exec_query(allfunc):
    with lock:
        con = DBConnection.DBConnection()
        con.connect()

        parts = allfunc.split(";")  # put a semicolon ; after the first word (function name)
        func = parts[0]
        if len(parts) == 1:
            func = getattr(con, func)
            response = func()
            return response
        if len(parts) > 1:
            args = parts[1].split(":")  # put a colon : between function parameters
            func = getattr(con, func)
            response = func(*args)
            return response
コード例 #7
0
ファイル: interface.py プロジェクト: edubrunaldi/labedet5
 def __init__(self):
     self.master = tkinter.Tk()
     self.master.title('Banco de Dados')
     tkinter.Frame.__init__(self, self.master)
     self.grid()
     self.BD = DBConnection.DBConnection()
     self.con = Connection(self.BD, self.error_window,
                           self.change_color_connect)
     self.ins = Insert(self.BD, self.error_window)
     self.rem = Remove(self.BD, self.error_window)
     self.up = Update(self.BD, self.error_window)
     self.cons = Consult(self.BD, self.error_window)
     self.login = None
     self.senha = None
     self.button_add_field = None
     self.number_table_fields = 0
     self.new_win = None
     self.fields_table = []
     self.create_widget_first()
コード例 #8
0
    def __init__(self):
        self._dbConnection = DBConnection()
        # set false to add readability columns to PostBlockVersion
        self._postBlockVersionAltered = True
        # set false to add readability columns to PostHistory
        self._postHistoryAltered = True
        # set false to add readability columns to Posts
        self._postsAltered = True

        # create indices for the sotorrent database
        # self._dbConnection.create_indices()

        # add readability measures to blocks
        # self.postblockversion_readability()

        # add readability measures to posthistory
        # self.posthistory_readability()

        #add readability measures to posts
        self.posts_readability()
コード例 #9
0
ファイル: csvLoader.py プロジェクト: avinashse/CSVLoaderGUI
    def __init__(self,createAndCtlStatementGUI):
        super().__init__()
        self.gridLayout_2 = QtWidgets.QGridLayout(createAndCtlStatementGUI)
        self.gridLayoutTextBrowser = QtWidgets.QGridLayout()
        self.textBrowser = QtWidgets.QTextBrowser(createAndCtlStatementGUI)
        self.lineEditBrowse = QtWidgets.QLineEdit(createAndCtlStatementGUI)
        self.btnBrowse = QtWidgets.QPushButton(createAndCtlStatementGUI)
        self.gridLayoutTreeView = QtWidgets.QGridLayout()
        self.treeViewDBConn = QtWidgets.QTreeView(createAndCtlStatementGUI)
        self.btnAddDBConn = QtWidgets.QPushButton(createAndCtlStatementGUI)
        self.checkBoxHasHearder = QtWidgets.QCheckBox(createAndCtlStatementGUI)
        self.checkBoxHasDataType = QtWidgets.QCheckBox(createAndCtlStatementGUI)
        self.radioButtonisMultipleFile = QtWidgets.QRadioButton(createAndCtlStatementGUI)
        self.radioBtnIsSingleFile = QtWidgets.QRadioButton(createAndCtlStatementGUI)
        self.btnLoadData = QtWidgets.QPushButton(createAndCtlStatementGUI)

        self.threadTextBrowser = threading.Thread(target=self.readQueueForTextBrowser,  daemon=True)

        self.dbDictList = objXmlReader.loadDBDetails()
        self.createAndCtlStatementGUI = createAndCtlStatementGUI
        self.setupUi(createAndCtlStatementGUI)
        self.dbConnectionObj = DBConnection()
        self.dbConn = None
コード例 #10
0
ファイル: DBOperation.py プロジェクト: HarryTu/PyStock
    def __init__(self):

        self.pool = DBConnection.DBConnection().CreateConnectionPool()
コード例 #11
0
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, WipeTransition

import DBConnection, classes
# from flashcards_test.main import *

Builder.load_file("main.kv")
Builder.load_file("learningWindows.kv")
sm = ScreenManager()
sm.transition = WipeTransition(clearcolor=(1, 1, 1, 1))

mail = ""
flashcard_set = classes.Set("1", "a")
current_sets = {}

db_x = DBConnection.DBConnection()
コード例 #12
0
    measures_df['revenue'] = (measures_df['quantity_ordered'] *
                              measures_df['price_each'])
    measures_df['costs'] = (measures_df['quantity_ordered'] *
                            measures_df['buy_price'])
    measures_df['profits'] = (measures_df['revenue'] - measures_df['costs'])
    measures_df['profit_per_item'] = (measures_df['profits'] /
                                      measures_df['quantity_ordered'])
    measures_df['profit_margin'] = (measures_df['profits'] /
                                    measures_df['revenue'])


###-###-###-###-###-###-###-###-###-###-###-###-###-###-###-###-###-###-###-
# Run script
###-###-###-###-###-###-###-###-###-###-###-###-###-###-###-###-###-###-###-
if __name__ == "__main__":
    conn_op_db = DBConnection.DBConnection(dbname="company_db")
    conn_star_db = DBConnection.DBConnection(dbname="star_db")

    # Using an ordered dictionary as the measures table must be loaded last
    query_dict = OrderedDict([('dim_employees', select_employees_query),
                              ('dim_offices', select_offices_query),
                              ('dim_products', select_products_query),
                              ('dim_orders', select_orders_query),
                              ('dim_customers', select_customers_query),
                              ('dim_dates', select_dates_query),
                              ('fact_order_items', join_query)])
    for key in query_dict.keys():
        print(f"Starting ETL of {key}... ", end="")
        etl_table(query_dict[key], conn_op_db, conn_star_db, key)
        print(f"complete")
    print("ETL complete.")
コード例 #13
0
ファイル: monitor.py プロジェクト: raabsm/system_health
else:
    import UK_Constants as constants


#tornado.options.define('port', default=constants.port, help='port to listen on')

currency = constants.currency

uri = constants.uri

connection = pymongo.MongoClient(uri)
mongo_db = connection['MyDatabase']
api_doc_id = constants.api_doc_id
error_doc_id = constants.error_doc_id

sql_db_connection = DBConnection.DBConnection(constants.prod_connection_string)


def format_number(entry):
    if entry is None:
        return '0'
    return "{:,}".format(round(entry))


def format_time(time):
    if time is not None:
        utc_time = pytz.utc.localize(time)
        israel_timezone = pytz.timezone('Israel')
        israel = utc_time.astimezone(israel_timezone)
        return israel.strftime("%H:%M")
    else:
コード例 #14
0
import pytest
import DBConnection
from datetime import datetime

test_conn = DBConnection.DBConnection("test_virtualspiceapp", "spice",
                                      "SpiceAdmin", "SpiceAdmin123")
test_conn.print_results(test_conn.find_all_items())


def check_if_database_is_not_empty():
    test_all_items = test_conn.get_count_of_all_items()
    return test_all_items > 0


def test_insert_single_element_status_code():
    test_conn.insert_single_item_to_db("Alma", datetime.now(),
                                       "sustainable food")


def test_insert_single_element_is_exist():
    test_food = test_conn.find_items_by_name("Alma")
    assert test_food is not None


def test_check_if_only_one_element_exist_in_db():
    test_number_of_elements = test_conn.get_count_of_all_items()
    assert test_number_of_elements == 1


def test_insert_single_element_is_exist():
    test_food = test_conn.find_items_by_name("Alma")
コード例 #15
0
 def setUp(self):
     self.dbConnection = DBConnection.DBConnection(
         '../Config/SampleDBConfig.xml')
コード例 #16
0
ファイル: LibraryDB.py プロジェクト: skibold/tkinter-example
	def __init__(self, logfile=None):
		self.logfile = logfile
		self.db = DBConnection("library", logfile)
		self.db.connect()
コード例 #17
0
ファイル: setup.py プロジェクト: rubiruchi/wsnserver
    if argsArray['rmCMD']:
        controller = Controller.Controller()
        controller.removeAllCMDAction()
        print 'All CMD`s removed.'

    if argsArray['sqlite3']:
        # creating/writing the database settings to the configuration file
        configurator = ConfigParser.RawConfigParser()
        configurator.add_section('Database-Config')
        configurator.set('Database-Config', 'type', 'sqlite3')

        with open('wsn.cfg', 'wb') as configfile:
            configurator.write(configfile)

        # get the connection object for creating the tables
        connection = DBConnection.DBConnection().getDBConnection()
        cursor = connection.cursor()

        cursor.execute("""CREATE TABLE data(
            id TEXT, value TEXT, read INTEGER, createdOn TEXT)""")

        cursor.execute(
            """CREATE TABLE devices(id TEXT, panid TEXT, channel TEXT)""")

        cursor.execute("""CREATE TABLE commands(id TEXT, cmd TEXT, 
                          read INTEGER, createdOn TEXT)""")

        connection.commit()
        connection.close()

        print("SQLite database has been created.")
コード例 #18
0
ファイル: DataRepository.py プロジェクト: rubiruchi/wsnserver
 def __returnConnection(self):
     return DBConnection.DBConnection().getDBConnection()
コード例 #19
0
 def __init__(self, verbose=False):
     # establish connection to db
     self.conn = DBConnection.DBConnection()
     self.verbose = verbose
コード例 #20
0
	def __init__(self):
        	self.conn1 = DBConnection.DBConnection()
コード例 #21
0
 def __init__(self, verbose=False):
     self.conn = DBConnection.DBConnection()
     self.verbose = verbose
コード例 #22
0
ファイル: TestDB.py プロジェクト: ocielliottc/autobuild
 def __init__(self, dbname):
     self.test_ids = {}
     self.build_ids = {}
     self.build_instance_ids = {}
     self.connection = DBConnection(dbname)
     self.curs = self.connection.curs
コード例 #23
0
 def __init__(self):
     self.dbc = DBConnection()
     self.postBlockVersionAltered = True
     self.postHistoryAltered = True
     self.postsAltered = True
     self.commentsAltered = True