Common
Common modules
For example testing database connection and CRUD we use sqlite3 become_qa_auto.db
This module defines the class Database to connect & manipulate DB data.
Database
Defines several methods to connect & CRUD DB data.
Source code in modules/common/database.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
__init__()
Set connection to DB file.
Source code in modules/common/database.py
10 11 12 13 |
|
delete_product_by_id(product_id)
Deleting product by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
product_id |
int
|
product ID |
required |
Source code in modules/common/database.py
94 95 96 97 98 99 100 101 102 |
|
get_all_users()
Get the rows of a query result all customers from DB.
Returns:
Type | Description |
---|---|
list
|
List of tuples with data |
Source code in modules/common/database.py
26 27 28 29 30 31 32 33 34 35 |
|
get_detailed_orders()
Get detailed info about orders with JOIN.
Returns:
Type | Description |
---|---|
list
|
List of tuples with data |
Source code in modules/common/database.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
get_user_address_by_name(name)
Get data by name from DB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Customer's name |
required |
Returns:
Type | Description |
---|---|
list
|
List of tuples with data |
Source code in modules/common/database.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
insert_product(product_id, name, description, qnt)
Inserts or replace product
Parameters:
Name | Type | Description | Default |
---|---|---|---|
product_id |
int
|
product ID |
required |
name |
str
|
name of the product |
required |
description |
str
|
Some text for the description |
required |
qnt |
int
|
quantity of the product |
required |
Source code in modules/common/database.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
select_product_qnt_by_id(product_id)
Get quantity product by ID
Parameters:
Name | Type | Description | Default |
---|---|---|---|
product_id |
int
|
product ID |
required |
Returns:
Type | Description |
---|---|
list
|
List of tuples with data |
Source code in modules/common/database.py
63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
test_connection()
Test connection to DB.
Returns:
Type | Description |
---|---|
None
|
print sqlite version |
Source code in modules/common/database.py
15 16 17 18 19 20 21 22 23 24 |
|
update_product_qnt_by_id(product_id, qnt)
Update quantity product by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
product_id |
int
|
product ID |
required |
qnt |
int
|
product quantity |
required |
Source code in modules/common/database.py
52 53 54 55 56 57 58 59 60 61 |
|