Description of specific Python Database Management

Source: Internet
Author: User

Python-specific databases in Python allow Python programmers to easily create a complete GUI with full function keys, this article provides the source code of the complete memory pool management program and test program for managing memory in a Python-specific database for your reference!

Just like Python and wxWidgets, a specific Python database is also an open-source software with excellent cross-platform capabilities in Russia, supports running on 32-bit windows, most Unix or Unix-like systems, and Macintosh OS X.

Zipfile is used to compress and decompress zip files in python. Because it is a common zip format, this module is frequently used, here we will record how to use zipfile. That is, it is convenient for you and others. Zipfile contains two very important classes.

ZipFile and ZipInfo. In most cases, we only need to use these two classes. ZipFile is the main class used to create and read zip files, while ZipInfo is the information of each file stored in the zip file. Here, z. infolist () is used, and it returns information of all files in the compressed package, which is a ZipInfo list. A ZopInfo object contains information about a file in the compressed package.

The commonly used types are filename, file_size, and header_offset, which are file names, file sizes, and file data offsets in the compressed package. In fact, the previous z. namelist () is the filename in the read ZopInfo to form a list to return. The ZipFile read method is used to extract a file from the compressed package:

 
 
  1. Import zipfile, OS
  2.  
  3. Z=Zipfile. ZipFile (filename, 'w') # note that the second parameter here is w, and the filename here is the name of the compressed package.
  4.  
  5. # Suppose you want to add all the files named testdir to the compressed package. Here, only the files in the first-level subdirectory are added ):
  6. If OS. path. isdir (testdir ):
  7. For d in OS. listdir (testdir ):
  8. Z. write (testdir + OS. sep + d)
  9. # Close () is required!
  10. Z. close ()

Object relationship Ing tools help increase productivity by providing classes and objects used to operate database tables. The best object-relationship ing tool for a Python-specific database is SQLObject, an open source project that performs almost all the operations required for programming the database. This topic describes SQLObject and its functions. After reading this article, you will be able to connect Python to the database without writing any SQL code.

When the object-oriented programming example satisfies the relational examples of most databases, the object relationship ing is usually seen. Object relationship ing is a bridge between the two worlds. It allows you to define classes corresponding to database tables. Then you can use these classes and their methods on the instance to interact with the database, instead of writing SQL. Using Object link ing does not mean that you do not need to know how relational databases work, but do not need to write SQL statements to avoid programming errors.

You can find more than a dozen open-source Python packages for Operating SQL databases. This does not include the special-purpose modules used to connect to a specific Python database. SQLObject is the best module. It is a simple and easy-to-use full object link ing package. SQLObject can complete almost all the operations required by the programming database.

This article shows how SQLObject interacts with the database, how to use SQLObject to write database access and data verification code, and how to use it for legacy or existing databases. Assume that you have knowledge of Python and relational databases.

  1. How to embed Python into C ++ applications?
  2. In-depth discussion of Ruby and Python syntax comparison
  3. Introduction to Python
  4. Python Learning Experience: version, IDE selection and coding Solutions
  5. Analysis of Python GIL and thread security

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.