Shiba-Py-Mysql
Shiba-Py-Mysql is a lightweight Python library that provides a convenient interface for interacting with MySQL databases using the pymysql library. It simplifies common database administration tasks such as creating databases, selecting databases, creating tables, and performing basic CRUD operations.
Features
- Easy database creation and selection.
- Table creation with support for different column types.
- Retrieving data from tables with support for JSON fields.
Installation
You can install Shiba-Py-Mysql using pip:
pip install shiba-mysql
import shiba as s
# Create a connection to the MySQL database
connection = s.ShibaConnection(host='localhost', port=3306, user='myuser', password='mypassword')
# Create a new database
connection.create_database('my_database')
# Select the database
connection.use_database('my_database')
# Create a table
table_builder = connection.create_table('users')
table_builder.increments('id')
table_builder.string('name', 20)
table_builder.integer('age')
table_builder.text('languages')
table_builder.text('settings')
table_builder.build()
# Insert data into the table
data_single = {
"name": "John",
"age": 30,
"languages": json.dumps(["Python", "JavaScript", "Java"]),
"settings": json.dumps({"theme": "dark", "notifications": True})
}
data_list = [
{
"name": "Alice",
"age": 25,
"languages": json.dumps(["Python", "C++"]),
"settings": json.dumps({"theme": "light", "notifications": False})
},
{
"name": "Bob",
"age": 35,
"languages": json.dumps(["JavaScript", "TypeScript"]),
"settings": json.dumps({"theme": "dark", "notifications": True})
}
]
cx.table('users').insert(data_single)
cx.table('users').insert(data_list)
x = cx.table("users").get()
for e in x:
for k, v in e.items():
if k == "languages":
languages = json.loads(v)
languages_str = ", ".join(languages)
print(f"Languages: {languages_str}")
elif k == "settings":
settings_str = json.loads(v)
print(f"Settings\n Theme: {settings_str['theme']}\n Notifications: {settings_str['notifications']}")
else:
print(f"{k}: {str(v)}")
LICENSE
This project is under the MIT License.
Change log
========== 1.0.0 (14/07/2023)
- FIRST RELEASE
- CREATE MODEL
========= 1.1.0 (15/07/2023)
-
SECODN RELEASE
-
ADD METHOD TABLE BUILDER: BINARY
-
ADD METHOD TABLE BUILDER: BOOLEAN
-
ADD METHOD TABLE BUILDER: CHAR
-
ADD METHOD TABLE BUILDER: TIME
-
ADD METHOD TABLE BUILDER: DATE
-
ADD METHOD TABLE BUILDER: DATETIME
-
ADD METHOD TABLE BUILDER: ENUM
-
ADD METHOD TABLE BUILDER: FOREIGN KEY
-
BUG FIX TABLE BUILDER: PRIMARY KEY
========= 1.2.0 (19/07/2023)
- THIRD RELEASE
- ADD METHOD: JOIN
- ADD METHOD: INNER JOIN
- ADD METHOD: RIGHT JOIN
- ADD METHOD: LEFT JOIN
- ADD METHOD: CROSS JOIN
- ADD METHOD: WHERE (support for multi-conditions)
- ADD METHOD: WHERE (support for single condition)
Metadata
Release files for shiba-mysql 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shiba_mysql-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for shiba_mysql-1.2.0-py3-none-any.whl |
Release files / shiba_mysql-1.2.0-py3-none-any.whl
| Download URL | shiba_mysql-1.2.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5399dc81b1c62adc67109d94c189d5f3eb251496651dfbfd131630820587042d
|
|
BLAKE2b-256 checksum How to use checksums |
18fe46a5e997e19c45d0a050ea97deaa804946e12d9ff59d469934b471d64d8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Security for shiba-mysql 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.