-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_MySQL.py
85 lines (67 loc) · 2.28 KB
/
test_MySQL.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
import mysql.connector
def create_database():
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd=""
)
mycursor = mydb.cursor()
mycursor.execute("CREATE DATABASE test_db")
def new_odom_table():
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="",
database="test_db"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE TABLE odom_data (id int not null auto_increment primary key, "
"position_x float, "
"position_y float, "
"theta_data float, "
"vel_linear float, "
"vel_angule float)")
def new_test_table():
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="",
database="test_db"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE TABLE time_record (id int not null auto_increment primary key, "
"classify_time float, "
"frame_time float)")
def test_float_table():
mydb = mysql.connector.connect(
host="localhost",
user="root",
passwd="123123",
database="test_db"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE TABLE test (id int not null auto_increment primary key, "
"position_x decimal(10, 2), "
"position_y decimal(10, 2), "
"theta_data decimal(10, 2), "
"vel_linear decimal(10, 2), "
"vel_angule decimal(10, 2))")
def insert_test():
my_db = mysql.connector.connect(
host="localhost",
user="root",
passwd="123123",
database="test_db"
)
my_cursor = my_db.cursor()
sql = "INSERT INTO test (position_x, position_y, theta_data, vel_linear, vel_angule) VALUES (%i, %i, %i, %i, %i)"
val = [
('Google', 'https://www.google.com'),
('Github', 'https://www.github.com'),
('Taobao', 'https://www.taobao.com'),
('stackoverflow', 'https://www.stackoverflow.com/')
]
my_cursor.execute("SHOW TABLES")
for x in my_cursor:
print(x)
new_test_table()