Inserting multiple rows using executemany command in mysql

While creating a table in a database, a row marked as “AUTO_INCREMENT” is necessary for multiple inserting:

1
2
3
4
5
6
7
8
CREATE TABLE university (
id int(8) NOT NULL AUTO_INCREMENT,
#without AUTO_INCREMENT, there will be an error while inserting multiple rows
name varchar(50) NOT NULL,
university varchar(50) NOT NULL,
major varchar(50) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

Then, create an array of the tuples you want to insert:

1
2
3
4
5
6
data = [("abc",'四川大学','口腔医学'),
("def",'北京师范大学','教育学类'),
("ghi",'北京工业大学','数学类'),
("jkl",'北京邮电大学','电子信息'),
("mno",'北京理工大学','未来精工技术'),
]

And use executemany command to insert:

1
2
3
4
5
6
7
8
9
try:
# 执行sql语句,插入多条数据
cursor.executemany("insert into university(name, university, major) values (%s, %s, %s)" , data)
# 提交数据
db.commit()
except:
# 发生错误时回滚
db.rollback()
print('error')

lines about connecting to database and ceating cursor instance is ignored

Creating a virtual machine (ubuntu) with virtual box

Yesterday, I created a virtual machine for ubuntu system using VirtualBox.

  1. Download the iso file of the operating system:
    ubuntu.iso
  2. Open VirtualBox, then choose the corresponding operating system:
    VirtualBox1
  3. Mount the iso file on VirtualBox:
    VirtualBox
  4. Format the disk space.
  5. Complete the regular settings.
  6. Set network adapters:
    _ there can be multiple adapters
    _ For my virtual machine, one adapter is used for NAT, the other one is used to connect to the host through ssh
    image
  7. remotely connect to the virtual machine through ssh:
    On host system, search for folder .ssh . There should be a public key id_rsa.pub .
    Then open it either using
    1
    cat id_rsa.pub
    or
    1
    vim id_rsa.pub
    Switch to the virtual machine, again, find .ssh folder and open it with
    1
    vim authorized_keys
    and paste the public key to the file, then save and close the file with
    1
    :wq [ENTER]
  8. Use
    1
    ip a
    to chech the ip address of the virtual machine, and connect to the virtual machine through ssh remotely.

image gallery constructed

Agian, I moved a step forward to mastering markdown by using skilfful copy-pasting.

Pages
log folder
log.js
log.json
log.wxml
log.wxss

Testing the images

chisato

url: /assets/chisato.jpg

chisato

url: https://user-images.githubusercontent.com/60023638/177815981-3059b9b2-8228-492e-bc63-2c3d592643e3.jpg

I tried to make the picture shown as part of the title of this post, which can then be displayed on homepage fo the website, and failed.
another thing worth to mention here is that, the first picture is first uploaded to the assets directory and then refered in this file. In this way, it has to be refered using a relative link. I know the first picture fails to display when you check this file on github, but it works on my website.
and the second is directly uploaded to this file, which works well as usual.

Mastering the website?!

As you can see, I’ve successfully created a ‘category’ page (basically copy-pasting from others’ work though).
And here I’m trying to upload the first picture of my website:
5dedfb1f3a292df5e335e5c0f9315c6035a87370
looks good.

A brand new site looks awkward

Finally I make it, though it embodies a total simplism. Well, it’s fine as long as it is useful… What’s the pupose of this website anyway?

I've passed the Subject 2 exam

Congratulations!! I’m heading to Subject 3 at 60km/h hahaha…

I'm meeting an error this fast?!

I haven’t expected to meet another problem since I struggled to create the website 10min ago.
The thing is the description of the posts cannot be displayed, which means my complaints in this post cannot be displayed neither.
But I’m still writing to curse this whole pile of not-looking-good codes, which does no good.