Giter Club home page Giter Club logo

pydbm's People

Contributors

hakancelikdev avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

pydbm's Issues

Try to support, date and datetime

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.

Use open's flag to separate readers and writers, handler multiple ops at a same time

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.

https://www.gnu.org.ua/software/gdbm/manual/Intro.html

Using objects is really necessary?

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?

Add a migration param to config class for automatic database migration.

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)

Support embed model

  • Suppor embed model
  • Use warnings when using dict instead of embed model
    • Create a model and load it using the dict data when using dict type instead of embed model.
  • Update documentation for this feature
  • Add tests

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.