Python Tutorial ( PDFDrive )

28.10.2021 Views

Python Database Access ...................................................... 338 What is MySQLdb? ................................................................................ 339 How do I install the MySQLdb? .............................................................. 339 Database Connection: ............................................................................ 339 EXAMPLE: ........................................................................................... 340 Creating Database Table: ...................................................................... 340 EXAMPLE: ............................................................................................. 340 INSERT Operation: ................................................................................ 341 TUTORIALS POINT Simply Easy Learning EXAMPLE: ........................................................................................... 341 EXAMPLE: ........................................................................................... 342 READ Operation: ................................................................................... 342 EXAMPLE: ........................................................................................... 342 Update Operation: .................................................................................. 343 EXAMPLE: ............................................................................................. 343 DELETE Operation: ............................................................................... 344 EXAMPLE: ........................................................................................... 344 Performing Transactions: ....................................................................... 344 EXAMPLE: ............................................................................................. 344 COMMIT Operation: ............................................................................... 345 ROLLBACK Operation: .......................................................................... 345 Disconnecting Database: ....................................................................... 345 Handling Errors: ..................................................................................... 345 Python Networking ................................................................ 347 What are Sockets? ................................................................................. 347 The socket Module: ................................................................................ 348 Server Socket Methods: ......................................................................... 348 Client Socket Methods: .......................................................................... 348 General Socket Methods: ....................................................................... 348 A Simple Server: .................................................................................... 348 A Simple Client: ...................................................................................... 349 Python Internet modules ........................................................................ 349 Further Readings: .................................................................................. 350 Python Sending Email ........................................................... 351 Example: ................................................................................................ 351 Sending an HTML e-mail using Python: ................................................. 352 EXAMPLE: ........................................................................................... 352 Sending Attachments as an e-mail: ....................................................... 353 EXAMPLE: ............................................................................................. 353 Python Multithreading ............................................................ 355

Starting a New Thread: .......................................................................... 355 EXAMPLE: ............................................................................................. 355 The Threading Module: .......................................................................... 356 Creating Thread using Threading Module: ............................................. 356 EXAMPLE: ........................................................................................... 357 Synchronizing Threads: ......................................................................... 358 EXAMPLE: ........................................................................................... 358 Multithreaded Priority Queue: ................................................................ 359 EXAMPLE: ........................................................................................... 359 Python XML Processing ........................................................ 361 XML Parser Architectures and APIs: ...................................................... 361 Parsing XML with SAX APIs: ................................................................. 362 The make_parser Method: ..................................................................... 362 The parse Method: ................................................................................. 363 The parseString Method: ........................................................................ 363 EXAMPLE: ........................................................................................... 363 Parsing XML with DOM APIs: ................................................................ 365 Python GUI Programming ..................................................... 367 Tkinter Programming .............................................................................. 367 Example: ................................................................................................ 367 Tkinter Widgets ...................................................................................... 368 Methods: ................................................................................................ 370 Example: ................................................................................................ 370 Example: ................................................................................................ 372 Methods: ................................................................................................ 375 Example: ................................................................................................ 375 Syntax: ................................................................................................... 376 Parameters: ............................................................................................ 376 Methods: ................................................................................................ 377 Example: ................................................................................................ 377 Syntax: ................................................................................................... 378 Parameters: ............................................................................................ 378 Example: ................................................................................................ 379 Syntax: ................................................................................................... 379 Parameters: ............................................................................................ 379 Example: ................................................................................................ 380 Syntax: ................................................................................................... 381 Parameters: ............................................................................................ 381 Methods: ................................................................................................ 382 TUTORIALS POINT Simply Easy Learning

Starting a New Thread: .......................................................................... 355

EXAMPLE: ............................................................................................. 355

The Threading Module: .......................................................................... 356

Creating Thread using Threading Module: ............................................. 356

EXAMPLE: ........................................................................................... 357

Synchronizing Threads: ......................................................................... 358

EXAMPLE: ........................................................................................... 358

Multithreaded Priority Queue: ................................................................ 359

EXAMPLE: ........................................................................................... 359

Python XML Processing ........................................................ 361

XML Parser Architectures and APIs: ...................................................... 361

Parsing XML with SAX APIs: ................................................................. 362

The make_parser Method: ..................................................................... 362

The parse Method: ................................................................................. 363

The parseString Method: ........................................................................ 363

EXAMPLE: ........................................................................................... 363

Parsing XML with DOM APIs: ................................................................ 365

Python GUI Programming ..................................................... 367

Tkinter Programming .............................................................................. 367

Example: ................................................................................................ 367

Tkinter Widgets ...................................................................................... 368

Methods: ................................................................................................ 370

Example: ................................................................................................ 370

Example: ................................................................................................ 372

Methods: ................................................................................................ 375

Example: ................................................................................................ 375

Syntax: ................................................................................................... 376

Parameters: ............................................................................................ 376

Methods: ................................................................................................ 377

Example: ................................................................................................ 377

Syntax: ................................................................................................... 378

Parameters: ............................................................................................ 378

Example: ................................................................................................ 379

Syntax: ................................................................................................... 379

Parameters: ............................................................................................ 379

Example: ................................................................................................ 380

Syntax: ................................................................................................... 381

Parameters: ............................................................................................ 381

Methods: ................................................................................................ 382

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!