Skip to main content


GitHub License GitHub branch check runs Static Badge GitHub Downloads (all assets, all releases)

English | 简体中文

Read full documentation at Read the Docs

MercurySQL (M.SQL)

Operate SQL in a more pythonic way.

What is it

Operate SQL database in a more Pythonic way.

  • Confused by complex SQL statements?
  • Lost data due to lack of commit?
  • Spent hours debugging SQL in the terminal?

Don't worry, I've been there too. That's why MercurySQL was born.

MercurySQL has the following advantages ....

  • More Pythonic way of operation: An API that is more in line with the Python style, making the operation of SQL databases more concise and easy to understand.
  • Avoid complex SQL statements: Avoid writing complex SQL statements, thereby reducing the burden of learning and understanding SQL syntax.
  • More secure database: Use safe queries, automatically commits for you, protect database security, and prevent data loss.
  • Debugging with Python: You can debug and check your database in Python directly, without complext SQL debugging in terminal.

For example, it can do these things....

Create Database

SQL

CREATE DATABASE IF NOT EXISTS test;

MercurySQL

db = DataBase('test')

Create Table

SQL

CREATE TABLE IF NOT EXISTS test (
    id INTEGER PRIMARY KEY
);

MercurySQL

table = db['test']
table.newColumn('id', int, primaryKey=True)

Delete Table

SQL

DROP TABLE IF EXISTS test;

MercurySQL

del db['test']

Add Column

SQL

ALTER TABLE test
ADD COLUMN name TEXT;

MercurySQL

table['name'] = str

Add Primary Key Column

SQL

ALTER TABLE test
ADD COLUMN id INTEGER PRIMARY KEY;

MercurySQL

table['id'] = int, 'Primary Key'  # 'Primary Key' is case-insensitive

Delete Column

SQL

ALTER TABLE table
DROP COLUMN name;

MercurySQL

del table['name']

Add Record

SQL

INSERT INTO test (id, name) VALUES (1, 'Bernie Huang');

MercurySQL

table.insert(id=1, name='Bernie Huang')

Query

SQL

SELECT * FROM test WHERE id=1 AND name='Bernie Huang';

MercurySQL

rec = table.select(
      (table['id'] == 1) & \
      (table['name'] == 'test')
)   # rec = [{'id': 1, 'name': 'Bernie Huang'}]

Delete Record

SQL

DELETE * FROM test WHERE id=1 AND name='Bernie Huang';

MercurySQL

((table['id'] == 1) & (table['name'] == 'test')).delete()

Dependencies:

  • sqlite3 (for Driver_SQLite, comes with Python)

    So ... no dependencies!


Why is it called MercurySQL

(===== The following is just some fun speculation by ChatGPT, don't mind it =====)

Speed and Agility: Mercury is the messenger god in ancient Roman mythology, and is synonymous with speed and flexibility. By putting "Mercury" in the name of the library, you might want to convey the speed and agility of this library when handling SQL databases.

Lightweight: Mercury is a relatively light metal, which may indicate that your library is designed to be lightweight, suitable for resource-sensitive environments such as embedded systems or mobile devices.

Fluidity: Mercury is a liquid metal at room temperature, with good fluidity. This may symbolize that your library provides a smooth API, making operations on SQL databases more flexible and easy.

Accuracy: Under temperature changes, mercury shows a stable volume, which makes it widely used in thermometers. This may indicate that your library is accurate and stable when handling data, with good reliability.

Chemical Stability: Mercury is a chemically stable element and does not easily react with other elements. This may mean that your library is stable and not prone to conflicts when integrated with other Python libraries or frameworks.

Metadata

Release files for MercurySQL 0.1.14

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

Source distribution (sdist)

Source distribution for MercurySQL 0.1.14
File Size Uploaded
mercurysql-0.1.14.tar.gz 18.9 kB Details

Release files / mercurysql-0.1.14.tar.gz

Download URL mercurysql-0.1.14.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a00c016b7f55a75820c815e7e2df7568a9e900bc4c5d0ab489cc03ba3eaf1fb7
BLAKE2b-256 checksum
How to use checksums
35949398713c29fd8d08660e8293b6fbaa9a4f58a14a2f1e1be09d17d1b80062
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.1.14 This release

1 release file

0.1.13

1 release file

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.1

2 release files

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