Skip to main content

MariaDB SQL Builder


License - GNU LPGL version 2.1 Python - ^3.7 Downloads

Security fix 1.1

If you are interested, the content is below

MariaDB license

This library uses MariaDB Connector/Python, which is released under the terms of the GPLv2 license. For more information, please see the license file in the repository.

Install

Install the package with pip pip install mariadb-sqlbuilder

Installation with pip + github pip install git+https://github.com/princessmiku/MariaDB-SQLBuilder

Setup

import mariadb_sqlbuilder

connection = mariadb_sqlbuilder.Connector(
    host="HostIP/URL",
    user="User",
    password="Password",
    database="DatabaseToConnect"
)

Example Functions

Select

result = connection.table("myTable").select("name, age, email").where("age", 25).fetchall()

Insert

connection.table("myTable").insert().set("id", 10).set("age", 25).set("Name", "Helgo").execute()

Wiki

For all Details and how to use

Functions

Content of the fix

I have found a security problem. Variables should be given directly to the cursor instead of writing them to the SQL. This prevents SQL injections.

By changing the avoidance of sql injection, the function “get_sql()” now returns “?” at the points where variables were before.

To get the variables back, there is now “values_for_execute”, which contains the variables in the correct order. The variables are returned in the type as they are stored. String as string, integer as integer, datetime as datetime...

Example

  • conn.table().update().values_for_execute
  • conn.table().select().values_for_execute

The variables are used in the statements where I suspect the possibility of SQL injection.

  • Setting variables
  • Where to query (conditions)

Setting keys or table names, for example, is normally not something a user should do, so they are written to SQL as normal.

I learned a lot while working on other projects. This has given me some knowledge about security. So I thought it was right to apply this to old projects as well.



Not completely used but
Translated with www.DeepL.com/Translator (free version)

Metadata

Release files for MariaDB-SQLBuilder 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for MariaDB-SQLBuilder 1.1.1
File Size Uploaded
mariadb_sqlbuilder-1.1.1.tar.gz 25.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for MariaDB-SQLBuilder 1.1.1
File Interpreter ABI Platform
MariaDB_SQLBuilder-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 60.6 kB

Release files / mariadb_sqlbuilder-1.1.1.tar.gz

Download URL mariadb_sqlbuilder-1.1.1.tar.gz
Size 25.6 kB
Tags Source
SHA-256 checksum
How to use checksums
99cdfd0ebeaa5e0e7ddf79cad51a75b96928ee23494830f3a76c34db63271522
BLAKE2b-256 checksum
How to use checksums
4751764b69a9c4074bc52a910d2cb65e259968e1b18d005f1dd93506cd3e280f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release files / MariaDB_SQLBuilder-1.1.1-py3-none-any.whl

Download URL MariaDB_SQLBuilder-1.1.1-py3-none-any.whl
Size 35.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c19b01bc87264ef9ca749c7709852bb0f67871c56d7ffc151316231f242d95eb
BLAKE2b-256 checksum
How to use checksums
de34fc9ab21416a7b2e190485b3e1959a96ba6add5d7fb1d81f6507dcc1893e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page