Skip to main content

lisa is an orm semi like django orm

Project description

**__# lisa-orm Lisa is an ORM semi like django ORM:

Available fields now:

- CharField()
- IntegerField()
- BooleanField()
- FloatField()
- TextField()
- DateField() -> not fully ready
- DateTimeField() -> not fully ready

Available actions now:

- add() -> to add recordes to DB
- drop() -> to drop tables(models)
- delete_field() -> to delete fields

Available search methods:

- get_all() -> to return all records in DB
- get() -> to return specific record in DB 
    - not finshed yet (only geting first record in DB now)

>> github

>> my linked in

>> my linktr.ee

>> my facebook

>> my twitter

>> my instagram


Getting started:

First: create your model:

  • create python file ex: my_model.py and write your model into it
from lisa_orm.db import models


class MyModel(metaclass=models.ModelMeta):
  table_name = 'my_table_name' # -> Name your model it's mandatory

  my_field_one = models.CharField(max_length=40, null=True)
  my_field_two = models.IntegerField(unique=True)
  • then run your model by pythonX my_model.py
  • X is python version

Second: make migrations:

  • create new file name it make_migrations.py
  • or name it anything you want
  • write into it:
from lisa_orm.migrations import make_migrations


make_migrations()
  • just run your make_migrations.py
  • by pythonX make_migrations.py

Third: migrate your model:

  • create file migrate.py
  • or anything you want
  • and write into it:
from lisa_orm.migrate import migrate


migrate()
  • run you migrate.py
  • by pythonX migrate.py

Note: I will make manage.py to make_migrations and migrate and some other actions (إن شاء الله)


Congratulations, you have just created your first model 😊


Now you can edit and add data and edit your model

  • let's add some data:

from lisa_orm.actions import add
from my_model import MyModel


add(
  model=MyModel,
  my_field_one = 'hello world!',
  my_field_two = 20
  )

add(
  model=MyModel,
  my_field_one = 'i love python',
  my_field_two = 50
  )

add(
  model=MyModel,
  my_field_one = 'i love lisa',
  my_field_two = 100
  )
  • now run your file pythonX run your_file.py
  • you should see this output :
data added successfully
data added successfully
data added successfully
  • you can delete a field from your model ... lets do it
from lisa_orm.actions import delete_field
from my_model import MyModel


delete_field(
   model=MyModel,
   field_name='my_field_two'
)
  • run your file

  • you should see this output: deleted field my_field_two successfully

  • And yo can drop your model also:

from lisa_orm.actions import drop
from my_model import MyModel

drop(model=MyModel)
  • run your file and you should see this output:
deleted model MyModel successfully

Let's get our data:

  • you can get your all data by get_all():

from lisa_orm.search import get_all
from my_model import MyModel

my_data_as_dict = get_all(model=MyModel)
my_data_as_json = get_all(model=MyModel, export_to_json=True)

# by default get_all and all methods in search  returns fetched data as a dict 
# but you can get data as json by passing export_to_json=True
  • you can also get 1 record from DB with get():

from lisa_orm.search import get
from my_model import MyModel

my_data_as_dict = get(model=MyModel)
my_data_as_json = get(model=MyModel, export_to_json=True)

# it is like get_all()
# It's not finished yet ... it is return only first record on DB

بس دي كل حاجة حتى الأن (:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lisa-orm-0.0.5.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

lisa_orm-0.0.5-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file lisa-orm-0.0.5.tar.gz.

File metadata

  • Download URL: lisa-orm-0.0.5.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10

File hashes

Hashes for lisa-orm-0.0.5.tar.gz
Algorithm Hash digest
SHA256 d9c41c8266456f4588ed8c54ba7c11fedac8fd42b4e86e74b1c521ae33e359ff
MD5 dc5cf6333810ee13791c0c6ef4498f76
BLAKE2b-256 185ae7dfb884a814bb70c3e5ed7e712239921091acdfbcc5f7cb59c52d8881a6

See more details on using hashes here.

File details

Details for the file lisa_orm-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: lisa_orm-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10

File hashes

Hashes for lisa_orm-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d0d9ea5fb1076c299882e0b83be6e4055a4c5c94d59f6a3f2499fa5f5c7d8579
MD5 d8ab29acc95e592f7f4110a71bc60168
BLAKE2b-256 3c671524c061994b11a6743bc6dab06d5c2e050bf18672d7a488a23de4492b99

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page