
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
A tool for easily adding database CRUD routes using pony orm and FastAPI. This package works with database definitions using the common pony orm data types, but it still needs to be tested on all of them.
using pip:
pip install fast-pony-crud
Define your database. You can do this in code, or you can use the Pony ORM online editor. You will end up with a file that looks something like this. save it as "db.py".
from datetime import datetime
from pony.orm import *
db = Database()
class Device(db.Entity):
name = PrimaryKey(str)
data_channels = Set('DataChannel')
class ChannelEntry(db.Entity):
id = PrimaryKey(int, auto=True)
time = Required(datetime,default=lambda:datetime.utcnow())
numeric_value = Optional(float)
metadata = Optional(Json)
data_channel = Required('DataChannel')
class DataChannel(db.Entity):
id = PrimaryKey(int, auto=True)
name = Required(str)
device = Required(Device)
device_time_entrys = Set(ChannelEntry)
data_type = Required('DataType')
class DataType(db.Entity):
id = PrimaryKey(str)
data_channels = Set(DataChannel)
metadata_config = Optional(Json)
Set up your API. Here we follow steps similar to the ones outlined in the FastAPI guide. The example uses an sqlite database for simplicity, but pony can connect to a variety of database backends. Save this file as "api.py".
from fastapi import FastAPI
from db import db # imports our database definition
from fast_pony_crud import create_crud_routes
import uvicorn
app = FastAPI()
# Connect to database
db.bind(provider='sqlite', filename='database.sqlite', create_db=True)
db.generate_mapping(create_tables=True)
# this is where the magic happens:
create_crud_routes(
db,
app,
prefix="/db", # prefix for all datbase crud routes
api_key="YOUR_SECRET_KEY") # api key for authentification sent on request headers
Launch the app by typing the following in your command shell:
uvicorn api:app --reload
Now you can view your api docs by going to http://127.0.0.1:8000/docs
FAQs
Tool for creating crud routes from pony database object
We found that fast-pony-crud 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 how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.