Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql.cursors
- from read_file import *
- cnx = pymysql.connect(user='root', password='ptekm8n8', host='127.0.0.1', database='productdb')
- cursor = cnx.cursor()
- def sql_stuff(object):
- query = ('INSERT INTO company (time_capacity) VALUES (%s);')
- query1 = ('INSERT INTO productdb (name, unit_cost) VALUES (%s);')
- cursor.execute(query, (Max_timer))
- for i, u, k in zip(VO, Timer_pr_enhed, name):
- uquery = ('INSERT INTO productdb (unit_cost, time_produce_minutes, name) VALUES (%s, %s, %s);')
- cursor.execute(uquery, (i, u, k))
- for i, u in zip(Salgspris1, Afsat1):
- uquery = ('INSERT INTO productinfo (unit_value, amount, product_id) VALUES (%s, %s, 1);')
- cursor.execute(uquery, (i, u))
- for i, u in zip(Salgspris2, Afsat2):
- uquery = ('INSERT INTO productinfo (unit_value, amount, product_id) VALUES (%s, %s, 2);')
- cursor.execute(uquery, (i, u))
- def udregninger(object):
- OMS = []
- for u, i in zip(Salgspris1, Afsat1):
- a = u * i
- OMS.append(a)
- def reset_database(object):
- reset = ('SET FOREIGN_KEY_CHECKS = 0; truncate company; truncate product_data; truncate productdb; truncate productinfo; SET FOREIGN_KEY_CHECKS = 1; commit')
- cursor.execute(reset)
- reset_database(object)
- sql_stuff(object)
- cnx.commit()
- cnx.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement