Add license, readme.

This commit is contained in:
Ege Emir Özkan
2020-08-01 16:57:37 +03:00
parent 42b707c869
commit 4cf92ca963
2 changed files with 48 additions and 0 deletions

7
LICENSE Normal file
View File

@@ -0,0 +1,7 @@
Copyright 2020 Ege Emir Özkan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

41
README.md Normal file
View File

@@ -0,0 +1,41 @@
# Datalite
Datalite is a simple Python
package that binds your dataclasses to a table in a sqlite3 database,
using it is extremely simple, say that you have a dataclass definition,
just add the decorator `@sqlify(db_name="db.db")` to the top of the
definition, and the dataclass will now be bound to the file `db.db`
For example:
```python
from dataclasses import dataclass
from datalite import sqlify
@sqlify(db_path="db.db")
@dataclass
class Student:
student_id: int
student_name: str = "John Smith"
```
This snippet will generate a table in the sqlite3 database file `db.db` with
table name `student` and rows `student_id`, `student_name` with datatypes
integer and text, respectively. The default value for `student_name` is
`John Smith`.
## Creating a new object instance
If you create a new object with default Python methods, the object will not
be inserted into the table by default. However, the classes that are created
with `datalite` has a argument in their init method. So, if you write
`Student(1, create_entry=True)` rather than just saying `Student(1)`, the
entry equivalent of the newly created student will be inserted into
the table without any problems.
## Deleting an object instance
Another method that is added to any dataclass created with `datalite` is the
`.remove()` method. By deleting a class with the `.remove()` you will also
delete its equivalent entry from the database.