Knowledgebase

Working With Databases Print

  • python, database, cpanel, security, woocommerce, guide, howto, solution
  • 0

Persistent structured storage.

WHEN TO USE ONE

Data that outlives the program Data several processes access More data than fits comfortably in memory Anything needing reliable updates

WHAT PYTHON INCLUDES

A lightweight file-based database, requiring nothing installed.

Excellent for small applications and local storage.

WHAT ELSE IS COMMON

Server databases, for larger applications and shared access.

On our hosting, MySQL or MariaDB through cPanel.

THE ESSENTIAL RULE

Never build queries by joining strings containing user input.

WHY

That is how injection vulnerabilities occur.

WHAT TO DO INSTEAD

Use parameterised queries, where values are passed separately from the statement.

Always. Without exception.

WHAT ELSE TO DO

Close connections Handle failures Use transactions where several changes must succeed together

WHAT AN ORM PROVIDES

A layer mapping database rows to Python objects.

Convenient for larger applications, and unnecessary for simple scripts.

WHAT TO STORE SECURELY

Database credentials, outside the code.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot