# database_wrapper_mysql
_Part of the `database_wrapper` package._
This python package is a database wrapper for [MySQL](https://www.mysql.com/) and [MariaDB](https://mariadb.org/) database.
## Installation
```bash
pip install database_wrapper[mysql]
```
## Usage
```python
from database_wrapper_mysql import MySQL, DBWrapperMySQL
db = MySQL({
"hostname": "localhost",
"port": 3306,
"username": "root",
"password": "your_password",
"database": "my_database"
})
db.open()
dbWrapper = DBWrapperMySQL(dbCursor=db.cursor)
# Simple query
aModel = MyModel()
res = await dbWrapper.getByKey(
aModel,
"id",
3005,
)
if res:
print(f"getByKey: {res.toDict()}")
else:
print("No results")
# Raw query
res = await dbWrapper.getAll(
aModel,
customQuery="""
SELECT t1.*, t2.name AS other_name
FROM my_table AS t1
LEFT JOIN other_table AS t2 ON t1.other_id = t2.id
"""
)
async for record in res:
print(f"getAll: {record.toDict()}")
else:
print("No results")
db.close()
```
Raw data
{
"_id": null,
"home_page": null,
"name": "database-wrapper-mysql",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "database, wrapper, python, mysql, mariadb",
"author": null,
"author_email": "Gints Murans <gm@gm.lv>",
"download_url": "https://files.pythonhosted.org/packages/b3/38/58d5f3fd303c4efed2f45a0028b6123ef01d56abcb88e8de67b4a6e68268/database_wrapper_mysql-0.1.73.tar.gz",
"platform": null,
"description": "# database_wrapper_mysql\n\n_Part of the `database_wrapper` package._\n\nThis python package is a database wrapper for [MySQL](https://www.mysql.com/) and [MariaDB](https://mariadb.org/) database.\n\n## Installation\n\n```bash\npip install database_wrapper[mysql]\n```\n\n## Usage\n\n```python\nfrom database_wrapper_mysql import MySQL, DBWrapperMySQL\n\ndb = MySQL({\n \"hostname\": \"localhost\",\n \"port\": 3306,\n \"username\": \"root\",\n \"password\": \"your_password\",\n \"database\": \"my_database\"\n})\ndb.open()\ndbWrapper = DBWrapperMySQL(dbCursor=db.cursor)\n\n# Simple query\naModel = MyModel()\nres = await dbWrapper.getByKey(\n aModel,\n \"id\",\n 3005,\n)\nif res:\n print(f\"getByKey: {res.toDict()}\")\nelse:\n print(\"No results\")\n\n# Raw query\nres = await dbWrapper.getAll(\n aModel,\n customQuery=\"\"\"\n SELECT t1.*, t2.name AS other_name\n FROM my_table AS t1\n LEFT JOIN other_table AS t2 ON t1.other_id = t2.id\n \"\"\"\n)\nasync for record in res:\n print(f\"getAll: {record.toDict()}\")\nelse:\n print(\"No results\")\n\ndb.close()\n```\n",
"bugtrack_url": null,
"license": "GNU General Public License v3.0 (GPL-3.0)",
"summary": "database_wrapper for MySQL database",
"version": "0.1.73",
"project_urls": {
"Changes": "https://github.com/gintsmurans/py_database_wrapper",
"Code": "https://github.com/gintsmurans/py_database_wrapper",
"Documentation": "https://github.com/gintsmurans/py_database_wrapper",
"Download": "https://pypi.org/project/database_wrapper/",
"Homepage": "https://github.com/gintsmurans/py_database_wrapper",
"Issue Tracker": "https://github.com/gintsmurans/py_database_wrapper/issues"
},
"split_keywords": [
"database",
" wrapper",
" python",
" mysql",
" mariadb"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2997e62ba0ad653dda4a7a50b408f89f1eb6271e2fd19736fe9c017b7b632286",
"md5": "14bd7d6609772b3623d4cb4eed583716",
"sha256": "e45472a27cde9f52454cbb2858c4c6a4aa981bfa765d59e11ceb882594e6a7ea"
},
"downloads": -1,
"filename": "database_wrapper_mysql-0.1.73-py3-none-any.whl",
"has_sig": false,
"md5_digest": "14bd7d6609772b3623d4cb4eed583716",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4922,
"upload_time": "2024-12-22T02:13:01",
"upload_time_iso_8601": "2024-12-22T02:13:01.500064Z",
"url": "https://files.pythonhosted.org/packages/29/97/e62ba0ad653dda4a7a50b408f89f1eb6271e2fd19736fe9c017b7b632286/database_wrapper_mysql-0.1.73-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b33858d5f3fd303c4efed2f45a0028b6123ef01d56abcb88e8de67b4a6e68268",
"md5": "50b1205782fe59e08436133b048013c3",
"sha256": "027816e4ccb9564adeb69e415862b739dcbc54a87a8ddb2ea20c566ac76e3d90"
},
"downloads": -1,
"filename": "database_wrapper_mysql-0.1.73.tar.gz",
"has_sig": false,
"md5_digest": "50b1205782fe59e08436133b048013c3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 4182,
"upload_time": "2024-12-22T02:13:12",
"upload_time_iso_8601": "2024-12-22T02:13:12.576780Z",
"url": "https://files.pythonhosted.org/packages/b3/38/58d5f3fd303c4efed2f45a0028b6123ef01d56abcb88e8de67b4a6e68268/database_wrapper_mysql-0.1.73.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-22 02:13:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gintsmurans",
"github_project": "py_database_wrapper",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "database-wrapper-mysql"
}