-
Notifications
You must be signed in to change notification settings - Fork 0
/
Insertrecords
37 lines (31 loc) · 1.17 KB
/
Insertrecords
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
import mysql.connector
from mysql.connector import Error
try:
connection = mysql.connector.connect(host='127.0.0.1',
database='order_schema',
user='root',
password='root')
if connection.is_connected():
db_Info = connection.get_server_info()
print("Connected to MySQL Server version ", db_Info)
cursor = connection.cursor()
cursor.execute("select database();")
record = cursor.fetchone()
print("Your connected to database: ", record)
except Error as e:
print("Error while connecting to MySQL", e)
finally:
if (connection.is_connected()):
print("You can insert data now")
count = 1000000
add_employee = ("INSERT INTO orders_table "
"(equipment_uuid, attribute, value, category_id, category_item_id) "
"VALUES (%s, %s, %s, %s, %s)")
data_employee = ('5', 'color', 'blackmamba', '5', '5')
cou = 0
for i in range(count):
cursor.execute(add_employee, data_employee)
connection.commit()
print("inserting record", i)
cursor.close()
connection.close()