PYTHON-DB Module

Source: Internet
Author: User

Design of interface test framework based on Python connection database

The first is to connect the database operations, preferably written in a single module,

Then convenient to call, based on the connection connection in the __init__ () method

The delete SELECT INSERT upddate is then defined separately.

Call the DB directly in the other file. DELETE (table_name) to use this method

The code is as follows:

The first is the primer package, here to note is to download the driver module: pymysql

Then the initialization part, in fact, is to put some configuration of the connection database here, do the connection

The next step is to write the Delete method,

The method is simple, just do not forget, execute a SQL, to connection commit!!!!

This is important, if the database is not committed

Next up is SELECT, Update, select, and you don't say a word.

Finally, it is recommended to remember the test data after completion!!!

So as not to cause trouble for others to test

You can debug it while you're writing. After all, it's important to use your own habits.

PYTHON-DB Module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.