Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Library made for testing.
You can use 2 types of imports: from mazga_db import MazgaDB
or import mazga_db.MazgaDB
Field | Type | Description |
---|---|---|
db | str | database name |
data_classes | dict | data_class (not required to use) |
Class creation
db - write with extension
data_classes - takes the form {'users': People..}
from MazgaDB import MazgaDB
db = MazgaDB('users.db', {'users': People})
Field | Type | Description |
---|---|---|
name_table | str | table name |
param | dict | table options |
Adds a table to the database
Param only takes this form {'column_name1': 'data_type1', 'column_name2': 'data_type2'...}
Accepts data type only from sqlite3
from mazga_db import MazgaDB
db = MazgaDB('users.db')
db.create_table('users',{'id':'INT', 'fname':'TEXT'})
id | fname |
---|---|
Field | Type | Description |
---|---|---|
name_table | str | table name |
values | list | string values |
Adds a line to the table
db = MazgaDB('users.db')
db.append_line('users', [1,'Mazga'])
id | fname |
---|---|
1 | Mazga |
Field | Type | Description |
---|---|---|
name_table | str | table name |
key1 | str | key (column) |
value1 | str | key1 value |
key2 | str | key (column) |
value2 | str | key2 value |
Updates objects by criteria for certain data
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
Field | Type | Description |
---|---|---|
name_table | str | table name |
key | str | key(column) |
value | str | key value |
Removes a line from the table
db = MazgaDB('users.db')
db.delete_line('users', key = 'id', value = 1)
id | fname |
---|---|
Field | Type | Description |
---|---|---|
name_table | str | table name |
name_column | str | column name |
type_column | str | column type |
Adds a column to the table
type_column
- accepts only types from sqlite3
db = MazgaDB('users.db')
db.append_column('users', 'lname', 'TEXT')
id | fname | lname |
---|---|---|
1 | Mazga | None |
Field | Type | Description |
---|---|---|
name_table | str | table name |
column | str | column name |
Deletes a column in the table
type_column
- accepts only types from sqlite3
db = MazgaDB('users.db')
db.delete_column('users', 'lname')
id | fname |
---|---|
1 | Mazga |
Field | Type | Description |
---|---|---|
name_table | str | table name |
key | str | key(column) |
value | str | key value |
Regular SELECT from sqlite3
db = MazgaDB('users.db')
db.select('users', key = 'id', value = '1')
[(1, 'Mazga')]
Field | Type | Description |
---|---|---|
name_table | str | table name |
key | str | key(column) |
value | str | key value |
class_data | None | class to return |
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()
db = MazgaDB('users.db')
db.select_class('users', key = 'id', value = '1', class_data = People)
People(id = 1, fname = 'Mazga')
db = MazgaDB('users.db', {'users': People})
db.select_class('users', key = 'id', value = '1')
People(id = 1, fname = 'Mazga')
db = MazgaDB('users.db')
db.select_class('users', key = 'id', value = '1')
Users(id = 1, fname = 'Mazga')
Field | Type | Description |
---|---|---|
name_table | str | table name |
type | str | type table |
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
db = MazgaDB('users.db')
db.read_table('users')
id | fname |
---|---|
1 | Mazga |
Accepts nothing
db = MazgaDB('users.db')
db.saw_tables()
[('users')]
Field | Type | Description |
---|---|---|
sql_request | str | sql request |
param | list | column name |
Normal execute
from sqlite3
(no need to write db.conn.commit()
, it's already built into the functions)
db = MazgaDB('users.db')
db.execute('SELECT * FROM users')
[(1, 'Mazga')]
FAQs
ОРМ для базы данных SQlite
We found that MazgaDB demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.