def log_and_load_database(auth):
    conn = SQL.establish_connection_with_base("postgres", auth)
    cursor = conn.cursor()

    try:
        cursor.execute('''DROP DATABASE tg;''')
    except Exception:
        print("there were no DataBase")

    cursor.execute('CREATE DATABASE tg;')

    conn = SQL.establish_connection_with_base("tg", auth)
    cursor = conn.cursor()

    nazwy_tabel = [
        'bron', 'bronbiala', 'granaty', 'celowniki', 'amunicja', 'dodatki',
        'szpej', 'plyty_balistyczne', 'tarcze', 'apteczki',
        'radia_i_komunikacja', 'jedzenie', 'zestawy_dajace_premie', 'drobnica',
        'gotowe_zestawy', 'mundury'
    ]
    zasieg_danych = [
        'O232', 'I20', 'I10', 'I25', 'I36', 'H5', 'I40', 'G9', 'G4', 'G11',
        'H10', 'F7', 'D6', 'D37', 'D6', 'F8'
    ]

    przetwornik = excel.Loader('TabelaBroni.xlsx', nazwy_tabel, zasieg_danych)
    dane = przetwornik.zwroc()
    przetwornik.wyczysc()

    for table in range(0, len(dane)):
        SQL.convert_excel_into_table(nazwy_tabel[table], dane[table], cursor)
    return conn
Exemple #2
0
    def __init__(self, update=False):

        auth = FilesMenagment.OtworzPlik(
            "LogiDoBazy.env"
        )  # to this file enter name of database, and password in second line
        if update:
            SQL_creator.log_and_load_database(
                auth)  #to update just uncomment this line
        conn = SQL.establish_connection_with_base("tg", auth)
        self.cursor = conn.cursor()
Exemple #3
0
 def wyszukaj_przedmiot_i_zwroc_po_wszystkim_z_nazwa_tabeli(self, nazwa):
     nazwa = nazwa.replace("\'", "\'\'")
     nazwy_tabel = [
         'bron', 'bronbiala', 'granaty', 'celowniki', 'amunicja', 'dodatki',
         'szpej', 'plyty_balistyczne', 'tarcze', 'apteczki',
         'radia_i_komunikacja', 'jedzenie', 'zestawy_dajace_premie',
         'drobnica', 'gotowe_zestawy', 'mundury'
     ]
     for tabela in nazwy_tabel:
         rekord = SQL.get_item_from_table(nazwa, tabela, self.cursor)
         if rekord:
             return [rekord, tabela]
     return False
def test():
    auth = FilesMenagment.OtworzPlik(
        "LogiDoBazy.env"
    )  # to this file enter name of database, and password in second line
    log_and_load_database(auth)  #to update just uncomment this line
    conn = SQL.establish_connection_with_base("tg", auth)
    cursor = conn.cursor()

    #cursor.execute('select * FROM bron')
    #print(cursor.fetchall())
    #
    #print(SQL.get_item_from_table("m4a1", 'bron', cursor))

    conn.close()


#test()
Exemple #5
0
 def luskacz_dodatkow(self, nazwa):
     nazwa = nazwa.replace("\'", "\'\'")
     return SQL.get_item_from_table(nazwa, 'dodatki', self.cursor)
Exemple #6
0
 def luskacz_amunicji(self, nazwa):
     nazwa = nazwa.replace("\'", "\'\'")
     return SQL.get_item_from_table(nazwa, 'amunicja', self.cursor)
Exemple #7
0
 def luskacz_granatow(self, nazwa):
     nazwa = nazwa.replace("\'", "\'\'")
     return SQL.get_item_from_table(nazwa, 'granaty', self.cursor)
Exemple #8
0
 def luskacz_broni_bialej(self, nazwa):
     nazwa = nazwa.replace("\'", "\'\'")
     return SQL.get_item_from_table(nazwa, 'bronbiala', self.cursor)