-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_db.py
206 lines (173 loc) · 5.55 KB
/
create_db.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import sqlite3
import pandas as pd
# Load the CSV data
df = pd.read_csv('csv/ofas.csv', sep=';') # "ofa"; "dte"; "uusr"; "usr"; "shift"; "ope"; "qty_ok"; "qty_ko"; "defaults"; "comments"
# Define the SQLite database
conn = sqlite3.connect('database2.db')
cursor = conn.cursor()
# Drop the table if it already exists
cursor.execute('DROP TABLE IF EXISTS ofas')
# Create the table
cursor.execute('''
CREATE TABLE ofas (
LOT_REFCOMPL TEXT,
LOT_RELEASED_QTY INTEGER,
LOT_REJECT_RELEASED_QTY INTEGER,
FAC_REFERENCE TEXT,
SCS_STEP_NUMBER INTEGER,
TAS_REF TEXT,
SCS_SHORT_DESCR TEXT,
TAL_RELEASE_QTY INTEGER,
TAL_REJECTED_QTY INTEGER,
TAL_BEGIN_REAL_DATE TEXT,
TAL_END_REAL_DATE TEXT
)
''')
# Process the DataFrame and insert data into the database
for index, row in df.iterrows():
cursor.execute('''
INSERT INTO ofas (LOT_REFCOMPL, LOT_RELEASED_QTY, LOT_REJECT_RELEASED_QTY, FAC_REFERENCE, SCS_STEP_NUMBER, TAS_REF, SCS_SHORT_DESCR, TAL_RELEASE_QTY, TAL_REJECTED_QTY, TAL_BEGIN_REAL_DATE, TAL_END_REAL_DATE)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (
row.iloc[0], row.iloc[1], row.iloc[2], row.iloc[3], row.iloc[4], row.iloc[5],
row.iloc[6], row.iloc[7], row.iloc[8], row.iloc[9], row.iloc[10]
))
# Commit the transaction and close the connection
conn.commit()
conn.close()
# Load the CSV data
df = pd.read_csv('csv/pp_tracking.csv', sep=';') # ofa; dte; uusr; usr; shift; ope; qty_ok; qty_ko; defaults; comments
# Define the SQLite database
conn = sqlite3.connect('database1.db')
cursor = conn.cursor()
# Drop the table if it already exists
cursor.execute('DROP TABLE IF EXISTS pp_tracking')
# Create the table
cursor.execute('''
CREATE TABLE pp_tracking (
ofa TEXT,
dte TEXT,
uusr TEXT,
usr TEXT,
shift INTEGER,
ope TEXT,
qty_ok INTEGER,
qty_ko INTEGER,
defaults TEXT,
comments TEXT
)
''')
# Process the DataFrame and insert data into the database
for index, row in df.iterrows():
cursor.execute('''
INSERT INTO pp_tracking (ofa, dte, uusr, usr, shift, ope, qty_ok, qty_ko, defaults, comments)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (row.iloc[0], row.iloc[1], row.iloc[2], row.iloc[3], row.iloc[4], row.iloc[5],
row.iloc[6], row.iloc[7], row.iloc[8], row.iloc[9]
))
# Commit the transaction and close the connection
conn.commit()
conn.close()
# Load the CSV data
df = pd.read_csv('csv/defaults.csv', sep=';') # "def_id"; "def_name"; "def_descr"; "def_domain";
# Define the SQLite database
conn = sqlite3.connect('database1.db')
cursor = conn.cursor()
# Drop the table if it already exists
cursor.execute('DROP TABLE IF EXISTS prod_defaults')
# Create the table
cursor.execute('''
CREATE TABLE prod_defaults (
def_id INT,
def_name TEXT,
def_descr TEXT,
def_domain TEXT
)
''')
# Process the DataFrame and insert data into the database
for index, row in df.iterrows():
cursor.execute('''
INSERT INTO prod_defaults (def_id, def_name, def_descr, def_domain)
VALUES (?, ?, ?, ?)
''', (row.iloc[0], row.iloc[1], row.iloc[2], row.iloc[3]
))
# Commit the transaction and close the connection
conn.commit()
conn.close()
# Load the CSV data
df = pd.read_csv('csv/pp_tracking.csv', sep=';')
# Define the SQLite database
conn = sqlite3.connect('database1.db')
cursor = conn.cursor()
# Drop the table if it already exists
cursor.execute('DROP TABLE IF EXISTS pp_tracking')
# Create the table
cursor.execute('''
CREATE TABLE pp_tracking (
ofa TEXT,
dte TEXT,
uusr TEXT,
usr TEXT,
shift INTEGER,
ope TEXT,
qty_ok INTEGER,
qty_ko INTEGER,
defaults TEXT,
comments TEXT
)
''')
# Process the DataFrame and insert data into the database
for index, row in df.iterrows():
cursor.execute('''
INSERT INTO pp_tracking (ofa, dte, uusr, usr, shift, ope, qty_ok, qty_ko, defaults, comments)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (row.iloc[0], row.iloc[1], row.iloc[2], row.iloc[3], row.iloc[4], row.iloc[5],
row.iloc[6], row.iloc[7], row.iloc[8], row.iloc[9]
)
)
# Commit the transaction and close the connection
conn.commit()
conn.close()
# Load the CSV data
df = pd.read_csv('csv/smc_tracking.csv', sep=';') # id; usr; dte; shift; pdc; qty_ok; qty_ko; d0; d1; d2; d3; d4; d5; d6; comments; ofa; week; defaults
# Define the SQLite database
conn = sqlite3.connect('database1.db')
cursor = conn.cursor()
# Drop the table if it already exists
cursor.execute('DROP TABLE IF EXISTS uu_tracking')
# Create the table
cursor.execute('''
CREATE TABLE uu_tracking (
id INTEGER,
usr TEXT,
dte TEXT,
shift INTEGER,
pdc TEXT,
qty_ok INTEGER,
qty_ko INTEGER,
d0 INTEGER,
d1 INTEGER,
d2 INTEGER,
d3 INTEGER,
d4 INTEGER,
d5 INTEGER,
d6 INTEGER,
comments TEXT,
ofa TEXT,
week TEXT,
defaults TEXT
)
''')
# Process the DataFrame and insert data into the database
for index, row in df.iterrows():
cursor.execute('''
INSERT INTO uu_tracking (id, usr, dte, shift, pdc, qty_ok, qty_ko, d0, d1, d2, d3, d4, d5, d6, comments, ofa, week, defaults)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''', (row.iloc[0], row.iloc[1], row.iloc[2], row.iloc[3], row.iloc[4], row.iloc[5],
row.iloc[6], row.iloc[7], row.iloc[8], row.iloc[9], row.iloc[10], row.iloc[11],
row.iloc[12], row.iloc[13], row.iloc[14], row.iloc[15], row.iloc[16], row.iloc[17]
)
)
# Commit the transaction and close the connection
conn.commit()
conn.close()