Skip to main content

easy calls to mysql databases

Project description

A lightweight and dynamic wrapper around mysql.connector to simplify MySQL database interactions with schema-driven table creation, automatic connection handling, and Python object mapping.


pip install easy-mysql


📁 Project Structure

Your project must include a schemas/ folder (or custom path) containing JSON schema files for each database.

Example:

schemas/
└── mydatabase.json

in this case the database name will be 'mydatabase'

Each file should follow this format:

{
  "users": {
    "name": "VARCHAR(255)",
    "email": "VARCHAR(255)",
    "active": "BOOLEAN"
  },
  
  "products": {
    "title": "VARCHAR(255)",
    "price": "FLOAT",
    "users_id": "INT"
  }
}

to use FOREIGN KEY create an INT column <foreign_table>_id: for example in the schema above users_id will be assosiated with the table users

🚀 Usage Example

from easy_mysql import Database, DatabaseCreds

# Define credentials
creds = DatabaseCreds(
    host="localhost",
    user="root",
    password="yourpassword",
    port=3306
)

# Initialize database (auto-creates DB and tables if they don't exist)
db = Database(name="mydatabase", creds=creds)

# Add object
user_id = db.add_object("users", {
    "name": "Alice",
    "email": "alice@example.com",
    "active": True
})

# Get list of user objects
users = db.get_list_of_objects("users")

# Get user by ID
user = db.get_object_by_id("users", user_id)

# Update user
db.update_object("users", user_id, {"active": False})

# Delete user
db.delete_object("users", user_id)

🔍 Advanced Usage

Get filtered list of objects:

db.get_filtered_list_of_objects(
    object_type="users",
    filter="alice",
    include_columns=['name', 'email']
    as_dict=True
)

📄 License

MIT License. See LICENSE file for details.


---

Let me know if you'd like to add badges (PyPI version, license, etc.) to the top of the README.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mysql_database-0.1.5.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mysql_database-0.1.5-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file mysql_database-0.1.5.tar.gz.

File metadata

  • Download URL: mysql_database-0.1.5.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mysql_database-0.1.5.tar.gz
Algorithm Hash digest
SHA256 0d600106fe65491fe79ab7dad6b4670bca9ea07dc29088fa1101c67aff4511a4
MD5 33c7d734271b5e63eb61dff677e148c0
BLAKE2b-256 b675a31993e75323ceca09518c4270cf55cd5cdd9dd488f1912640c99dafbcf8

See more details on using hashes here.

File details

Details for the file mysql_database-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: mysql_database-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mysql_database-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a51e6bedd063208bb2ecbf03c7c40c8f0de5acc6ece3454d9e92caf8442f1bab
MD5 22386b381bc256eb725a5aba35093a83
BLAKE2b-256 a838ef71d655e7f77ff6428cacc165db931fae484207fcd36c3372f54fbbbcfe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page