# Documentation MazgaDB
Library made for testing.
## Import
You can use 2 types of imports: ```from mazga_db import MazgaDB``` or ```import mazga_db.MazgaDB```
## Class
| Field | Type | Description |
|-------|----------|---------|
| db | ```str``` | database name |
| data_classes | ```dict``` | data_class (not required to use) |
#### Description
Class creation
db - write with extension
data_classes - takes the form ```{'users': People..}```
#### Example:
```
from MazgaDB import MazgaDB
db = MazgaDB('users.db', {'users': People})
```
## Methods
### create_table
| Field | Type | Description |
|-------|----------|---------|
| name_table | ```str``` | table name |
| param | ```dict``` | table options |
#### Description
Adds a table to the database
Param only takes this form ```{'column_name1': 'data_type1', 'column_name2': 'data_type2'...}```<br>
Accepts data type only from ```sqlite3```
#### Example:
```
from mazga_db import MazgaDB
db = MazgaDB('users.db')
db.create_table('users',{'id':'INT', 'fname':'TEXT'})
```
| id | fname |
|-------|----------|
| | |
### append_line
| Field | Type | Description |
|-------|----------|---------|
| name_table | ```str``` | table name |
| values | ```list``` |string values |
#### Description
Adds a line to the table
#### Example:
```
db = MazgaDB('users.db')
db.append_line('users', [1,'Mazga'])
```
| id | fname |
|-------|----------|
| 1 | Mazga|
### update_line
| Field | Type | Description |
|-------|----------|---------|
| name_table | ```str``` | table name |
| key1 | ```str``` |key (column) |
|value1 | ```str``` | key1 value|
| key2 | ```str``` |key (column) |
|value2| ```str``` | key2 value|
#### Description
Updates objects by criteria for certain data
#### Example:
```
db = MazgaDB('users.db')
db.update_line('users', key1 = 'id', value1 = '1', key2 = 'fname', value2 = 'Mazga2')
```
| id | fname |
|-------|----------|
| 1 | Mazga2|
We had a line with id 1 and a fname Mazga his fname changed to Mazga2
### delete_line
| Field | Type | Description |
|-------|----------|---------|
| name_table | ```str``` | table name |
| key | ```str``` |key(column) |
|value| ```str``` | key value|
#### Description
Removes a line from the table
#### Example:
```
db = MazgaDB('users.db')
db.delete_line('users', key = 'id', value = 1)
```
| id | fname |
|-------|----------|
| | |
### append_column
| Field | Type | Description |
|-------|----------|---------|
| name_table | ```str``` | table name |
| name_column | ```str``` | column name |
|type_column| ```str``` | column type|
#### Description
Adds a column to the table
```type_column``` - accepts only types from ```sqlite3```
#### Example:
```
db = MazgaDB('users.db')
db.append_column('users', 'lname', 'TEXT')
```
| id | fname | lname |
|-------|----------|--------|
| 1 | Mazga| None|
### delete_column
| Field | Type | Description |
|-------|----------|---------|
| name_table | ```str``` | table name |
| column | ```str``` | column name |
#### Description
Deletes a column in the table
```type_column``` - accepts only types from ```sqlite3```
#### Example:
```
db = MazgaDB('users.db')
db.delete_column('users', 'lname')
```
| id | fname |
|-------|----------|
| 1 | Mazga|
### select
| Field | Type | Description |
|-------|----------|---------|
| name_table | ```str``` | table name |
| key | ```str``` |key(column) |
|value| ```str``` | key value|
#### Description
Regular SELECT from ```sqlite3```
#### Example:
```
db = MazgaDB('users.db')
db.select('users', key = 'id', value = '1')
```
#### Output:
```
[(1, 'Mazga')]
```
### select_class
| Field | Type | Description |
|-------|----------|---------|
| name_table | ```str``` | table name |
| key | ```str``` |key(column) |
|value| ```str``` | key value|
|class_data| ```None``` | class to return|
#### Description
Returns values as a class
If the class is not passed will take the class from data_classes (```{'name_table': class...}```),
If the class is not passed and not in dataclasses, will return a class with data, with class name ```name_table.title()```
#### Example1:
```
db = MazgaDB('users.db')
db.select_class('users', key = 'id', value = '1', class_data = People)
```
#### Output1:
```
People(id = 1, fname = 'Mazga')
```
#### Example2:
```
db = MazgaDB('users.db', {'users': People})
db.select_class('users', key = 'id', value = '1')
```
#### Output2:
```
People(id = 1, fname = 'Mazga')
```
#### Example3:
```
db = MazgaDB('users.db')
db.select_class('users', key = 'id', value = '1')
```
#### Output3:
```
Users(id = 1, fname = 'Mazga')
```
### read_table
| Field | Type | Description |
|-------|----------|---------|
| name_table | ```str``` | table name |
| type | ```str``` | type table |
#### Description
Returns a table of characters
There are only two types ```'s'```(string table) and ```'m'``` (Markdown table). If the wrong type is entered it will raise an error
#### Example1:
```
db = MazgaDB('users.db')
db.read_table('users')
```
#### Output1:
| id | fname |
|-------|----------|
| 1 | Mazga |
### saw_tables
#### Description
Accepts nothing
#### Example:
```
db = MazgaDB('users.db')
db.saw_tables()
```
#### Output:
```
[('users')]
```
### execute
| Field | Type | Description |
|-------|----------|---------|
| sql_request | ```str``` | sql request |
| param | ```list``` | column name |
#### Description
Normal ```execute``` from ```sqlite3``` (no need to write ```db.conn.commit()```, it's already built into the functions)
#### Example:
```
db = MazgaDB('users.db')
db.execute('SELECT * FROM users')
```
#### Output:
```
[(1, 'Mazga')]
```
Raw data
{
"_id": null,
"home_page": "https://github.com/Mazgagzam/MazgaDB",
"name": "MazgaDB",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "example python orm sql",
"author": "Mazga",
"author_email": "agzamikail@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/7b/34/9e1656194f92147fa3ee7fa544a101c746e7445ee4e50f85be508dfb21cf/MazgaDB-1.1.2.tar.gz",
"platform": null,
"description": "# Documentation MazgaDB\n\nLibrary made for testing.\n\n## Import\n\nYou can use 2 types of imports: ```from mazga_db import MazgaDB``` or ```import mazga_db.MazgaDB```\n\n## Class\n| Field | Type | Description |\n|-------|----------|---------|\n| db | ```str``` | database name |\n| data_classes | ```dict``` | data_class (not required to use) |\n\n#### Description\nClass creation\n\ndb - write with extension\ndata_classes - takes the form ```{'users': People..}```\n#### Example: \n```\nfrom MazgaDB import MazgaDB\ndb = MazgaDB('users.db', {'users': People})\n```\n\n## Methods\n### create_table\n| Field | Type | Description |\n|-------|----------|---------|\n| name_table | ```str``` | table name |\n| param | ```dict``` | table options |\n\n#### Description\n\nAdds a table to the database\n\nParam only takes this form ```{'column_name1': 'data_type1', 'column_name2': 'data_type2'...}```<br>\nAccepts data type only from ```sqlite3```\n\n#### Example: \n```\nfrom mazga_db import MazgaDB\ndb = MazgaDB('users.db')\ndb.create_table('users',{'id':'INT', 'fname':'TEXT'})\n```\n\n| id | fname | \n|-------|----------|\n| | |\n\n\n### append_line\n| Field | Type | Description |\n|-------|----------|---------|\n| name_table | ```str``` | table name |\n| values | ```list``` |string values |\n\n#### Description\nAdds a line to the table\n#### Example:\n```\ndb = MazgaDB('users.db')\ndb.append_line('users', [1,'Mazga'])\n```\n\n| id | fname | \n|-------|----------|\n| 1 | Mazga|\n\n### update_line\n| Field | Type | Description |\n|-------|----------|---------|\n| name_table | ```str``` | table name |\n| key1 | ```str``` |key (column) |\n|value1 | ```str``` | key1 value|\n| key2 | ```str``` |key (column) |\n|value2| ```str``` | key2 value|\n\n#### Description\n\nUpdates objects by criteria for certain data\n\n#### Example:\n```\ndb = MazgaDB('users.db')\ndb.update_line('users', key1 = 'id', value1 = '1', key2 = 'fname', value2 = 'Mazga2')\n```\n\n| id | fname | \n|-------|----------|\n| 1 | Mazga2|\n\nWe had a line with id 1 and a fname Mazga his fname changed to Mazga2\n\n### delete_line\n| Field | Type | Description |\n|-------|----------|---------|\n| name_table | ```str``` | table name |\n| key | ```str``` |key(column) |\n|value| ```str``` | key value|\n\n#### Description\n\nRemoves a line from the table\n\n#### Example:\n```\ndb = MazgaDB('users.db')\ndb.delete_line('users', key = 'id', value = 1)\n```\n\n\n| id | fname | \n|-------|----------|\n| | |\n\n### append_column\n\n| Field | Type | Description |\n|-------|----------|---------|\n| name_table | ```str``` | table name |\n| name_column | ```str``` | column name |\n|type_column| ```str``` | column type|\n\n#### Description\n\nAdds a column to the table\n\n```type_column``` - accepts only types from ```sqlite3```\n\n#### Example:\n```\ndb = MazgaDB('users.db')\ndb.append_column('users', 'lname', 'TEXT')\n```\n\n| id | fname | lname |\n|-------|----------|--------|\n| 1 | Mazga| None|\n\n\n### delete_column\n\n| Field | Type | Description |\n|-------|----------|---------|\n| name_table | ```str``` | table name |\n| column | ```str``` | column name |\n\n#### Description\n\nDeletes a column in the table\n\n```type_column``` - accepts only types from ```sqlite3```\n\n#### Example:\n```\ndb = MazgaDB('users.db')\ndb.delete_column('users', 'lname')\n```\n\n| id | fname | \n|-------|----------|\n| 1 | Mazga|\n\n### select\n\n| Field | Type | Description |\n|-------|----------|---------|\n| name_table | ```str``` | table name |\n| key | ```str``` |key(column) |\n|value| ```str``` | key value|\n\n\n#### Description\nRegular SELECT from ```sqlite3```\n\n#### Example:\n```\ndb = MazgaDB('users.db')\ndb.select('users', key = 'id', value = '1')\n```\n#### Output:\n```\n[(1, 'Mazga')]\n```\n\n### select_class\n\n| Field | Type | Description |\n|-------|----------|---------|\n| name_table | ```str``` | table name |\n| key | ```str``` |key(column) |\n|value| ```str``` | key value|\n|class_data| ```None``` | class to return|\n\n#### Description\nReturns values as a class\n\nIf the class is not passed will take the class from data_classes (```{'name_table': class...}```), \n\nIf the class is not passed and not in dataclasses, will return a class with data, with class name ```name_table.title()``` \n\n#### Example1:\n```\ndb = MazgaDB('users.db')\ndb.select_class('users', key = 'id', value = '1', class_data = People)\n```\n#### Output1:\n```\nPeople(id = 1, fname = 'Mazga')\n```\n\n\n#### Example2:\n```\ndb = MazgaDB('users.db', {'users': People})\ndb.select_class('users', key = 'id', value = '1')\n```\n#### Output2:\n```\nPeople(id = 1, fname = 'Mazga')\n``` \n\n#### Example3:\n```\ndb = MazgaDB('users.db')\ndb.select_class('users', key = 'id', value = '1')\n```\n#### Output3:\n```\nUsers(id = 1, fname = 'Mazga')\n``` \n\n### read_table\n\n\n| Field | Type | Description |\n|-------|----------|---------|\n| name_table | ```str``` | table name |\n| type | ```str``` | type table |\n\n#### Description \nReturns a table of characters\nThere are only two types ```'s'```(string table) and ```'m'``` (Markdown table). If the wrong type is entered it will raise an error\n\n#### Example1:\n```\ndb = MazgaDB('users.db')\ndb.read_table('users')\n```\n#### Output1:\n\n| id | fname |\n|-------|----------|\n| 1 | Mazga |\n\n### saw_tables\n\n#### Description \nAccepts nothing\n\n#### Example:\n```\ndb = MazgaDB('users.db')\ndb.saw_tables()\n```\n#### Output:\n\n```\n[('users')]\n```\n\n### execute\n\n| Field | Type | Description |\n|-------|----------|---------|\n| sql_request | ```str``` | sql request |\n| param | ```list``` | column name |\n\n#### Description \nNormal ```execute``` from ```sqlite3``` (no need to write ```db.conn.commit()```, it's already built into the functions)\n#### Example:\n```\ndb = MazgaDB('users.db')\ndb.execute('SELECT * FROM users')\n```\n\n#### Output:\n```\n[(1, 'Mazga')]\n```\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "\u041e\u0420\u041c \u0434\u043b\u044f \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 SQlite",
"version": "1.1.2",
"project_urls": {
"Documentation": "https://github.com/Mazgagzam/MazgaDB",
"Homepage": "https://github.com/Mazgagzam/MazgaDB"
},
"split_keywords": [
"example",
"python",
"orm",
"sql"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d0c9634d11d743151b69e6abb96bfc86dacdf395a47d2639693bf2d862224138",
"md5": "16587e2d9004d48f235e611426538613",
"sha256": "391f006ad8c4bb1aef6326737b781e39f24d0a4a9ddc8b3ee977335c965e07ba"
},
"downloads": -1,
"filename": "MazgaDB-1.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "16587e2d9004d48f235e611426538613",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4346,
"upload_time": "2023-08-29T07:34:32",
"upload_time_iso_8601": "2023-08-29T07:34:32.162249Z",
"url": "https://files.pythonhosted.org/packages/d0/c9/634d11d743151b69e6abb96bfc86dacdf395a47d2639693bf2d862224138/MazgaDB-1.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7b349e1656194f92147fa3ee7fa544a101c746e7445ee4e50f85be508dfb21cf",
"md5": "2553a17a8993a18e93bba6a8937b398b",
"sha256": "69326dee7bf9245913356399c68fe21cfc60238cde77b1d1675d00f440d17e81"
},
"downloads": -1,
"filename": "MazgaDB-1.1.2.tar.gz",
"has_sig": false,
"md5_digest": "2553a17a8993a18e93bba6a8937b398b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 5103,
"upload_time": "2023-08-29T07:34:33",
"upload_time_iso_8601": "2023-08-29T07:34:33.240616Z",
"url": "https://files.pythonhosted.org/packages/7b/34/9e1656194f92147fa3ee7fa544a101c746e7445ee4e50f85be508dfb21cf/MazgaDB-1.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-29 07:34:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Mazgagzam",
"github_project": "MazgaDB",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "mazgadb"
}