Socket
Socket
Sign inDemoInstall

MazgaDB

Package Overview
Dependencies
1
Maintainers
1
Alerts
File Explorer

Install Socket

Protect your apps from supply chain attacks

Install

MazgaDB

ОРМ для базы данных SQlite

    1.1.2

Maintainers
1

Readme

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

FieldTypeDescription
dbstrdatabase name
data_classesdictdata_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

FieldTypeDescription
name_tablestrtable name
paramdicttable options
Description

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

Example:
from mazga_db import MazgaDB
db = MazgaDB('users.db')
db.create_table('users',{'id':'INT', 'fname':'TEXT'})
idfname

append_line

FieldTypeDescription
name_tablestrtable name
valuesliststring values
Description

Adds a line to the table

Example:
db = MazgaDB('users.db')
db.append_line('users', [1,'Mazga'])
idfname
1Mazga

update_line

FieldTypeDescription
name_tablestrtable name
key1strkey (column)
value1strkey1 value
key2strkey (column)
value2strkey2 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')
idfname
1Mazga2

We had a line with id 1 and a fname Mazga his fname changed to Mazga2

delete_line

FieldTypeDescription
name_tablestrtable name
keystrkey(column)
valuestrkey value
Description

Removes a line from the table

Example:
db = MazgaDB('users.db')
db.delete_line('users', key = 'id', value = 1)
idfname

append_column

FieldTypeDescription
name_tablestrtable name
name_columnstrcolumn name
type_columnstrcolumn 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')
idfnamelname
1MazgaNone

delete_column

FieldTypeDescription
name_tablestrtable name
columnstrcolumn 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')
idfname
1Mazga

select

FieldTypeDescription
name_tablestrtable name
keystrkey(column)
valuestrkey value
Description

Regular SELECT from sqlite3

Example:
db = MazgaDB('users.db')
db.select('users', key = 'id', value = '1')
Output:
[(1, 'Mazga')]

select_class

FieldTypeDescription
name_tablestrtable name
keystrkey(column)
valuestrkey value
class_dataNoneclass 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

FieldTypeDescription
name_tablestrtable name
typestrtype 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:
idfname
1Mazga

saw_tables

Description

Accepts nothing

Example:
db = MazgaDB('users.db')
db.saw_tables()
Output:
[('users')]

execute

FieldTypeDescription
sql_requeststrsql request
paramlistcolumn 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')]

Keywords

FAQs


Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc