ExenDB
A simple library that covers sqlite3's basic functionality.
Copyright 2022-present Exenifix. Licensed under MIT License, see LICENSE for details.
Installation
Using pip
$ python -m pip install -U exendb
# or
$ pip install -U exendb
From source
$ pip install -U git+https://github.com/Exenifix/ExenDB
Quickstart
Creating a table
from exendb import Database, SQLType
db = Database('test')
table = db.create_table(
'users',
id=SQLType.UNIQUE(SQLType.INT), #column named id with type INT with unique value
name=SQLType.TEXT, #named name, type TEXT
surname=SQLType.TEXT, #named surname, type TEXT
is_male=SQLType.BOOL) #named is_male, type BOOL
Adding values to table
...
table.insert_row(151, 'John', 'Wisley', True)
table.insert_row(157, 'Joe', 'Astley', True)
table.insert_row(651, 'Mary', 'Bart', False)
...
Getting dict-like values
...
all_rows = table.get_all_rows() #type: list[dict]
single_row = table.get_single_row('id = 151') #type: dict
...
Updating existing row
...
table.update('id = 651', name='Marie')
...
Deleting row
...
table.delete_row('name = "John" AND surname = "Wisley"')
...
More examples in sample_table.py
Classes
Database
Class representing a database.
Attributes
- name:
strName of the database (without file extension).
- file_name:
strFilename of the database we connect to.
- tables:
property, strList of tables that belong to this database.
Methods
-
get_table(name: str)->TableReturns
Tableobject if found in database's tables list. -
create_table(name: str, **columns: SQLType)->TableCreates a new table and returns
Tableobject. -
delete_table(name: str)Removes an existing table from the database.
-
select(*args, **kwargs)->Union[dict, list]Performs a
SELECTquery to the database.
Table
Class representing a database table. You don't construct this by yourself.
Attributes
- db:
DatabaseThe database this table belongs to.
- name:
strName of the table.
- columns:
property, list[str]List of column names.
Methods
-
rename(new_name: str)Renames the table to a new name.
-
delete()Deletes the table from the database.
-
add_column(name: str, _type: SQLType)Creates a new column with the given name and type.
-
remove_column(name: str)Removes a column with the given name.
-
rename_column(name: str, new_name: str)Renames a column with the given name to a new name.
-
get_single_row(*columns, where: str)Returns a SINGLE row of data in
dictformat, where keys are column names and values are rows values. -
get_multiple_rows(*columns, **kwargs)Returns all the rows matching the given conditions.
-
get_all_rows(*columns, **kwargs)Returns all the rows. Equivalent to to
get_multiple_rowswithoutwherekwarg. -
insert_row(*data)Inserts a row into the database for the given column names.
-
update(_where: str = None, **data)Sets the values of the row(s) meeting the condition to the new data.
-
delete_row(where: str):Deletes all the rows in the table meeting the condition.
Metadata
Release files for exendb 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| exendb-0.0.2.tar.gz | 8.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| exendb-0.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.6 kB
Release files / exendb-0.0.2.tar.gz
| Download URL | exendb-0.0.2.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
caf2d638ad39ce7facbbbf0f4d1973496e5dc16c59158e144d39d309e7969765
|
|
BLAKE2b-256 checksum How to use checksums |
7592c03e49ca30ed384f6edd564b221285e536644fff700881ddd6bbc83ad831
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / exendb-0.0.2-py3-none-any.whl
| Download URL | exendb-0.0.2-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7f8bb9114c1ad1ac450d1839da3e1860aa0d28dd964bae6f39b006d1f75cf592
|
|
BLAKE2b-256 checksum How to use checksums |
f21a3b8d3e5075950a21c2a6f3579de569d8cf2df6de1985581dbc293cb957bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|