Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
A Python object relational mapper for SQLite.
pip install simple-orm
Following a basic tutorial to demonstrate how to use the ORM.
Define a Post
model in a post.py
file.
# post.py
from orm import Model
class Post(Model):
text = str # other datatypes: int, float
def __init__(self, text):
self.text = text
Import Database
to create a data access object.
>>> from orm import Database
>>> db = Database('db.sqlite') # indicating a database file.
Import the Post
model and link it to the database.
>>> from post import Post
>>> Post.db = db # see another approach in tests.py
Create a post and save it in the staging area (without commit) of database.
>>> post = Post('Hello World').save()
>>> print(post.id) # auto generated id
1
Change the hello world post and update it in the database.
>>> post = Post.manager().get(id=1)
>>> post.text = 'Hello Mundo'
>>> post.update()
>>> post.text
Hello Mundo
Commit all staged operations (save
and update
) to the database.
>>> db.commit()
Delete the object and commit.
>>> post.delete()
>>> db.commit()
Create a manager that can perform CRUD operations in the database.
>>> objects = Post.manager(db)
Save and get a post.
>>> objects.save(Post('Hello', 'World'))
>>> objects.get(2) # get by id from the staging area
{'text': 'World', 'id': 2, 'title': 'Hello'}
Close the database without commit the changes
>>> db.close()
Get all posts from database.
>>> list(objects.all()) # return a "empty" generator
[]
Check code lint:
pip install pylint
pylint orm.py
See CONTRIBUTING.
The MIT License.
FAQs
A simple ORM for SQLite
We found that simple-orm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.