hakancelikdev / pydbm Goto Github PK
View Code? Open in Web Editor NEW:balloon: Pythonic way to use dbm.
Home Page: https://pydbm.hakancelik.dev
License: GNU General Public License v3.0
:balloon: Pythonic way to use dbm.
Home Page: https://pydbm.hakancelik.dev
License: GNU General Public License v3.0
date
Field value can be a date in the format
YYYY-MM-DD
.
datetime
Field value can be a date and time in the format
YYYY-MM-DD HH:MM:SS
.
GDBM
allows an application to have multiple databases open at the same time. When an application opens a GDBM
database, it is designated as a reader
or a writer
. A GDBM
database can be opened by at most one writer at a time. However, many readers may open the database simultaneously. Readers and writers can not open the GDBM
database at the same time.
Speaking about application we usually mean a separate process. However, it is entirely normal for a multi-thread program to operate as a GDBM
reader in one thread and writer in another, provided, of course, that the two threads don’t operate on the same database simultaneously.
Throw an exception when a non-existent field is entered on the model.
If there is no need to write a custom manager, I don't think it's necessary, yes, it's nice to reach by writing objects, yes it's a familiar usage, but is it really necessary?
just can change id creation behavior
class PyPIPackageModel(DbmModel):
username: str
class Config:
table_name = "usernames"
unique_together = ("username",)
class PyPIPackageModel(DbmModel):
user: str
class Config:
table_name = "usernames"
unique_together = ("user",)
migration = True
def set_database_header(self):
ann = get_obj_annotations(obj=self.model)
db_headers = bytes(str({key: DATABASE_HEADER_MAPPING[value] for key, value in ann.items()}), "utf-8")
with self as db:
database_header: bytes | None
if (database_header := db.get(DATABASE_HEADER_NAME, None)) is None or (database_header is not None and self.model._config.migration is True):
db[DATABASE_HEADER_NAME] = db_headers
else:
# TODO: migrations
assert database_header == db_headers, f"Database headers are not equal: '{database_header}' != '{db_headers}'" # type: ignore[str-bytes-safe] # noqa: E501
setattr(self, DATABASE_HEADER_NAME, ann)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.