Skip to main content

Easy DB

This simple and easy-to-use library comes with a few important functions to start storing data easier! It comes loaded with functions to read, write, and delete data. This doesn't require too much setup, but it still requires some user input and data to setup tables. Tables are made in JSON (JavaScript Object Notation), so they are very easy to read.

Dependencies

  • Python 3.8 or above

Docs

Table(filename, tablename) | Class

This is the table class, which holds all the information for one table.

Parameters

  • filename [type: string]: file the table will be or is stored in
  • tablename [type: string]: the name of your table

Attributes

  • deleted [type: boolean, default: False]: if the table is deleted (using a method in the class), the value of the variable changes to True, methods cannot be carried out without the variable being True
  • set [type: boolean, default: False]: value changes to True if table is set, methods cannot be carried out without the variable being True
  • filename [type: string]: file the table will be or is stored in
  • tablename [type: string]: the name of your table

Example

example = Table('example_file.json', 'Example Table')

Methods


setup_table(args, already_set)

Use
Sets up the table and sets the set attribute to True so that other methods in the table can be carried out.

Parameters

  • already_set [type: bool, default: False]: if the table is already setup, set the value to True and ignore args
  • args [type: list, default: None]: should be ignored if table is already setup, if table is not setup, this is a list all the columns of the table

Example
If table is not set

example.setup_table(args=['name', 'state', 'country'])

If table is set

example.setup_table(already_set=True)

apdata(primary_key, args)

Use
Can add and update rows of data using the primary key passed in.

Parameters

  • primary_key [type: string]: distinct identifier of each row in the table, if the primary key passed as a parameter doesn't exist in the table already a new row will be added with the primary key as the identifier, if the primary key already exists in the table all data corresponding to the primary key will be updated with new data
  • args [type: list]: the data corresponding to the primary, should be placed in the order of the table's columns

Raises

  • ValueError - if number of arguments does not correspond to the number of columns in the table

Example

example.apdata('Person1', ['John', 'Texas', 'US'])
# adds data to a table with the primary key as "Person1"

get_keys(*key)

Use
Returns data from specific columns in the form of a dictionary.

Parameters

  • key [type: string]: column names

Example

data = example.get_keys('name', 'state')
print(data)
# returns data from only the "name" and "state" column

get(primary_key)

Use
Returns all the data that corresponds to a primary key in the dictionary.

Parameters

  • primary_key [type: string]: the primary key that corresponds to the row of data you want to get

Example

data = example.get('Person1')
print(data)

delete(primary_key)

Use
Deletes a row from the table, using the primary key to identify the row.

Parameters

  • primary_key [type: string]: the primary key that corresponds to the row of data you want to delete

Example

example.delete('Person1')

req_args()

Use
Returns all the column names of the table.

Parameters
None

Example

arguments = example.req_args()
print(arguments)

check_if_table_setup()

Use
Checks if the table is setup and sets the set attribute to True.

Parameters
None

Raises

  • ValueError: if the table is not setup

Example

example.check_if_table_setup()

deltable()

Use
Deletes the table.

Parameters
None

Example

example.deltable()

check_if_table_is_deleted()

Use
Checks if the table is deleted and sets the deleted attribute to True.

Parameters
None

Raises

  • ValueError: if the table has been deleted

Example

example.check_if_table_is_deleted()

number_of_args()

Use
Returns the number of columns in the table.

Parameters
None

Example

number = example.number_of_args()
print(number)

number_of_rows()

Use
Returns the number of rows in the table.

Parameters
None

Example

number = example.number_of_rows()
print(number)

To-Do

  • Make CLI using EasyDB functions and classes

Release files for EasyDatabase 2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for EasyDatabase 2.1
File Size Uploaded
EasyDatabase-2.1.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for EasyDatabase 2.1
File Interpreter ABI Platform
EasyDatabase-2.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.1 kB

Release files / EasyDatabase-2.1.tar.gz

Download URL EasyDatabase-2.1.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
43c83e8b2a60fec18a020ee2bcde2d69a17051fc578d997da9de0518565ee3b9
BLAKE2b-256 checksum
How to use checksums
3e4eab95fd2b5992c60b9651895b50ead8932cdb610279fc08988377a11ebbad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

Release files / EasyDatabase-2.1-py3-none-any.whl

Download URL EasyDatabase-2.1-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b19eda8931c267789d8d2921dce5e58df594730c093c02359e9b088407f4f54
BLAKE2b-256 checksum
How to use checksums
7cf4a478a6f9240d0c4e87deccdc2dbd2849f704514a15c4ee41e4643a8b6c8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

2.1 This release

2 release files

2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page