Saravanan666/pypi-org huggingface dataset:
Package: peewee_encrypted_field
Encrypted field forPeewee ORMmodels to save data in DB in encrypted form.Data stored in DataBase asFernet tokens. After you define an encryption key all cryptography will be performed transparently for your application.Uses simple fernet implementationhttps://github.com/heroku/fernet-pyIdea caught from SQLAlchemy’sEncryptedType.ContentsImplementation DetailsFeaturesInstallationUsageKey Derivation ExampleImplementation DetailsAfernet-pypackage can usePycryptoorM2Cryptoas backend (details). Same belongs to this module due to its dependency fromfernet-py. Note thatpipusesPycryptoas a default dependency when installfernet-py.Length of entire key is 32 bytes, 16 bytes per both signing and encryption keys, as stated inspecification.FeaturesYou have to setkeyas a property of appropriateEncryptedField.You need to set this property once perModelperModel‘sField.
If you attempt to setkeyproperty for aFieldwhosekeyalready has been set, exceptionEncryptedField.KeyAlreadyExistswill be raised. To change thekeyon the fly you have to explictly performdel SomeEncryptedField.keyand then set this property to desired value again.Installationpip install peewee_encrypted_fieldor, if you downloaded source,python setup.py installUsageAt first, import modulefrompeeweeimport*frompeewee_encrypted_fieldimportEncryptedFieldThen, define the model withEncryptedFieldclassSecureTable(BaseModel):sensitive_data=EncryptedField()classMeta:db_table='SecureTable'After, configure field’s encryption keySecureTable.sensitive_data.key=key_derivation_fn()# a hypotetical key derivation# function returning 32 byte keyFinally, save and retrieve data in a Peewee’s usual mannernew_secret=SecureTable(sensitive_data='My New BIG Secret')new_secret.save()Key Derivation ExampleExample Key Derivation Function baded onPycryptomodule.Please take look at this Gist- it can contain more actual version of code below.frombinasciiimportunhexlifyfromfunctoolsimportpartialfromCrypto.ProtocolimportKDFfromCrypto.HashimportSHA512,HMAC_SALT=unhexlify('48B755AB80CD1C3DA61182D3DCD2E3A2CA869B783618FF6551FB4B0CDC3B8066')# some salt_KEY_LENGTH=32key_derivation_fn=partial(KDF.PBKDF2,salt=_SALT,dkLen=_KEY_LENGTH,count=5000,prf=lambdap,s:HMAC.new(p,s,SHA512).digest())# KDF usageSecureTable.sensitive_data.key=key_derivation_fn(text_password)
Package: peewee-enum-field
peewee-enum-fieldA custom field forPeewee, a small, expressive ORM, that allows for the easy integration of Python Enums in Peewee models.Overviewpeewee-enum-fieldprovides a convenient way to store Python Enum types in a Peewee database. This custom field stores the name of an Enum member as a string in the database and handles automatic conversion between the Enum type and the string representation when reading or writing to the database.InstallationTo installpeewee-enum-field, you can use pip:pipinstallpeewee-enum-fieldUsagefromenumimportEnumclassColor(Enum):RED=1GREEN=2BLUE=3Then, use EnumField in your Peewee model:importpeeweefrompeewee_enum_fieldimportEnumFieldclassMyModel(peewee.Model):color=EnumField(Color)You can now assign Enum members to the field, filter, etc:instance=MyModel.create(color=Color.RED)instance=MyModel.get(Color.color==Color.RED)The field automatically handles conversion to and from the Enum type:assertinstance.color==Color.REDFeaturesEasy integration with Peewee models.Stores the name of the Enum member in the database for readability.Automatically converts to and from the Python Enum type.RequirementsPython 3.6+PeeweeLicensepeewee-enum-field is released under theMIT License.
Package: peewee-erd
peewee ERDDraw ER diagram based on peewee models.This project is heavily based onhttps://github.com/gustavi/peewee-graph-models.InstallationTo install the peewee ERD usepip:$pipinstallpeewee-erdTo install the peewee ERD with live view usepipwith extras:$pipinstallpeewee-erd[live-view]UsageTo draw the diagram run it with the path of models file:$peewee-erd<paths_of_models_files>...For other variants of usage see help:$peewee-erd--helpExample outputThis is the ER diagram generated forconceptnet-lite:
Package: peewee-ext
Peewee-extGithub:https://github.com/mouday/peewee-extPypi:https://pypi.org/project/peewee-ext简介peewee-ext 对 peewee 进行了部分扩展，在其基础上进行了增强安装pip install peewee-ext使用方式1、连接方式的增强db_config={'scheme':'mysql',# 增加数据库类型'host':'127.0.0.1','port':3306,'user':'root','password':'123456','database':'data'}# 用peewee_ext.connect 替换peewee的connect# from playhouse.db_url import connectfrompeewee_extimportconnect# 可以传入关键字参数，当然第一个位置参数也支持url地址链接db=connect(**db_config)2、打印sql执行时间# from peewee import MySQLDatabasefrompeewee_extimportTimerMySQLDatabasedb_config={'host':'127.0.0.1','port':3306,'user':'root','password':'123456','database':'data'}# 打印sql执行时间# db = MySQLDatabase(**db_config)db=TimerMySQLDatabase(**db_config)# 对应connect参数 ：# 'scheme': 'mysql+timer'3、Model转dict字典对象frompeewee_extimportDictModel,to_dict,to_data# 用 DictModel 替换 Model# class BaseModel(Model):classBaseModel(DictModel):classMeta:database=db3.1、Model对象调用方法转dictmodel=BaseModel()model.to_data()model.to_dict()3.2、使用装饰器转dictfrompeewee_extimportto_dict,to_data# 装饰器将返回值是DictModel对象转换为dict，其他类型原样返回@to_dictdefget_row():"""可以返回 DictModel 或 List[DictModel]"""returnBaseModel.select().first()# 可选参数参考：playhouse.shortcuts.model_to_dict@to_datadefget_row():"""可以返回 DictModel 或 List[DictModel]"""returnBaseModel.select().first()说明增加一个 DictModel 增加两个方法frompeeweeimportModelclassDictModel(Model):defto_data(self,recurse=True,backrefs=False,only=None,exclude=None,seen=None,extra_attrs=None,fields_from_query=None,max_depth=None,manytomany=False):"""model to dict"""defto_dict(self):"""model to dict"""def__str__(self):"""friendly for human"""增加两个装饰器defto_dict(func):"""model to dict , shallow convert"""# 返回嵌套字典defto_data(func=None,recurse=True,backrefs=False,only=None,exclude=None,seen=None,extra_attrs=None,fields_from_query=None,max_depth=1,manytomany=False):"""model to dict , deep convert"""增加执行时间打印frompeeweeimportMySQLDatabase# 已注册scheme: 'mysql+timer'classTimerMySQLDatabase(MySQLDatabase):""""""
Package: peewee-jsonfield
JSONField for MySQL Peewee libraryThis package is a JSONField on steroids for use withORM Peewee,
adding functions for working with NoSQL data (JSON fields)By default, in Peewee, JSONField is a simple field inherited from TextField without any settings and additional methods, however,
in MySQL/MariaDB there aremany methodsfor working with JSON data that are either not used or
need to be implemented yourself. This package is designed to fix this situation.Installationpip install peewee-jsonfieldUsingSuppose you have a table with a JSON type field, for example:class TestModel(Model):
    id: int | AutoField = AutoField()
    data: dict | JSONField = JSONField()With this library, you can use the SQL methodJSON_SETusing a simple python-specific syntax:# Adding an integer variable to the "data" root
TestModel.data.jset('$.v_integer_key', 10).where(TestModel.id == 1).execute()# Adding an dict variable to the "data" root
query: ModelUpdate = TestModel.data.jset('$.v_dict_key', {'nested1': 10})
query = query.where(TestModel.id == 1)
# ... any other where
query.execute()You can use SQL methodJSON_MERGE_PATCHto add nested variables in dict:# Adding an nested dict variable to the root.v_dict_key
TestModel.data.jset('$.v_dict_key.nested_variable', 'nested_string').where(TestModel.id == 1).execute()

# Adding an nested list variable to the root.v_dict_key
TestModel.data.jset('$.v_dict_key.nested_list', [1, 2, 3]).where(TestModel.id == 1).execute()Also, if you already have an object, instead of completely overwriting (.save()), you can use theUPDATEfunctions, specifying it astargetandexecute=Trueif the request needs to be executed immediately:obj: TestModel = TestModel.get(TestModel.id == 1)
# some reading code
TestModel.data.jset('$.v_integer_key', 30, target=obj, execute=True)
TestModel.data.jset('$.v_string_key', 'testing new library', target=obj, execute=True)To remove fields from a JSON field, you can use the.jremove()method:TestModel.data.jremove('$.v_integer_key', target=obj, execute=True)
TestModel.data.jremove('$.v_dict_key.nested1', target=obj, execute=True)

# Query without WHERE
TestModel.data.jremove('$.v_string_key', execute=True)Additional optionsThis field can also take additional options from thedbhandleobject:dbhandle.json_ensure_ascii = True- setting theensure_asciiparameter in thejsonlibrary when saving data to the databasedbhandle.json_use_detailed = False- setting theindent=2parameter in thejsonlibrary and
using the intermediate SQL formatting functionJSON_DETAILEDwhen saving data to the databaseMore examples and tryView and run the filejsonfield_play.pyBefore starting, you need to set environment variables to access the database:db_name,db_port,db_passwdand others (db_host,db_port,opt_table_temporary,opt_json_ensure_ascii,opt_json_use_detailed) as neededTODOImplement arrays methodsAdd method's descriptionAdd basicjpathchecksLimitationsThis library is focused on working with MariaDB and MySQL DBMS and, most likely, will not work with others, since the syntax of SQL functions differs
Package: peewee-migrate
Peewee Migrate – A simple migration engine forPeeweeORMContentsRequirementsDependency NoteInstallationUsageFrom shellFrom pythonMigration filesBug trackerContributingRequirementspeewee >= 3.8Dependency NoteForPeewee<3.0please usePeewee-Migrate==0.14.0ForPython3.0-3.6please usePeewee-Migrate==1.1.6ForPython 3.7please usePeewee-Migrate==1.6.6InstallationPeewee Migrateshould be installed using pip:pip install peewee-migrateUsageDo you wantFlaskintegration? Look atFlask-PW.From shellGetting help:$ pw_migrate --help

Usage: pw_migrate [OPTIONS] COMMAND [ARGS]...

Options:
    --help  Show this message and exit.

Commands:
    create   Create migration.
    migrate  Run migrations.
    rollback Rollback migration.Create migration:$ pw_migrate create --help

Usage: pw_migrate create [OPTIONS] NAME

    Create migration.

Options:
    --auto                  FLAG  Scan sources and create db migrations automatically. Supports autodiscovery.
    --auto-source           TEXT  Set to python module path for changes autoscan (e.g. 'package.models'). Current directory will be recursively scanned by default.
    --database              TEXT  Database connection
    --directory             TEXT  Directory where migrations are stored
    -v, --verbose
    --help                        Show this message and exit.Run migrations:$ pw_migrate migrate --help

Usage: pw_migrate migrate [OPTIONS]

    Run migrations.

Options:
    --name TEXT       Select migration
    --database TEXT   Database connection
    --directory TEXT  Directory where migrations are stored
    -v, --verbose
    --help            Show this message and exit.Rollback migrations:$ pw_migrate rollback --help

Usage: pw_migrate rollback [OPTIONS]

    Rollback a migration with given steps --count of last migrations as integer number

Options:
    --count INTEGER   Number of last migrations to be rolled back.Ignored in
                        case of non-empty name

    --database TEXT   Database connection
    --directory TEXT  Directory where migrations are stored
    -v, --verbose
    --help            Show this message and exit.From pythonfrompeewee_migrateimportRouterfrompeeweeimportSqliteDatabaserouter=Router(SqliteDatabase('test.db'))# Create migrationrouter.create('migration_name')# Run migration/migrationsrouter.run('migration_name')# Run all unapplied migrationsrouter.run()Migration filesBy default, migration files are looked up inos.getcwd()/migrationsdirectory, but custom directory can be given.Migration files are sorted and applied in ascending order per their filename.Each migration file must specifymigrate()function and may specifyrollback()functiondefmigrate(migrator,database,fake=False,**kwargs):passdefrollback(migrator,database,fake=False,**kwargs):passBug trackerIf you have any suggestions, bug reports or
annoyances please report them to the issue tracker
athttps://github.com/klen/peewee_migrate/issuesContributingDevelopment of starter happens at github:https://github.com/klen/peewee_migrate
Package: peewee-migrate-dev
Peewee Migrate – A simple migration engine for PeeweeContentsRequirementsDependency NoteInstallationUsageFrom shellFrom pythonMigration filesBug trackerContributingContributorsLicenseRequirementspython 2.7,3.5peewee >= 3.3.1Dependency NoteForPeewee<3.0please usePeewee-Migrate==0.14.0.InstallationPeewee Migrateshould be installed using pip:pip install peewee_migrateUsageDo you wantFlaskintegration? Look atFlask-PW.From shellGetting help:$ pw_migrate --help

Usage: pw_migrate [OPTIONS] COMMAND [ARGS]...

Options:
    --help  Show this message and exit.

Commands:
    create   Create migration.
    migrate  Run migrations.
    rollback Rollback migration.Create migration:$ pw_migrate create --help

Usage: pw_migrate create [OPTIONS] NAME

    Create migration.

Options:
    --auto                  FLAG  Scan sources and create db migrations automatically. Supports autodiscovery.
    --auto-source           TEXT  Set to python module path for changes autoscan (e.g. 'package.models'). Current directory will be recursively scanned by default.
    --database              TEXT  Database connection
    --directory             TEXT  Directory where migrations are stored
    -v, --verbose
    --help                        Show this message and exit.Run migrations:$ pw_migrate migrate --help

Usage: pw_migrate migrate [OPTIONS]

    Run migrations.

Options:
    --name TEXT       Select migration
    --database TEXT   Database connection
    --directory TEXT  Directory where migrations are stored
    -v, --verbose
    --help            Show this message and exit.From pythonfrom peewee_migrate import Router
from peewee import SqliteDatabase

router = Router(SqliteDatabase('test.db'))

# Create migration
router.create('migration_name')

# Run migration/migrations
router.run('migration_name')

# Run all unapplied migrations
router.run()Migration filesBy default, migration files are looked up inos.getcwd()/migrationsdirectory, but custom directory can be given.Migration files are sorted and applied in ascending order per their filename.Each migration file must specifymigrate()function and may specifyrollback()function:def migrate(migrator, database, fake=False, **kwargs):
    pass

def rollback(migrator, database, fake=False, **kwargs):
    passBug trackerIf you have any suggestions, bug reports or
annoyances please report them to the issue tracker
athttps://github.com/klen/peewee_migrate/issuesContributingDevelopment of starter happens at github:https://github.com/klen/peewee_migrateContributorsSeeAUTHORS.rstLicenseLicensed under aBSD license.
Package: peewee-model-factory
peewee_model_factoryNo time? Ready to use?pip install peewee-model-factoryfrompeewee_model_factoryimportmodel_factoryfrommodelimportAuthor,Bookauthor=model_factory(Author,fill_nullable_values=True)book=model_factory(Book,author=author)Need custom type generation?importpeeweeaspwfrompeewee_model_factoryimportmodel_factorydefchar_field_factory(field:pw.Field)->str:returnf"my char value for field:{field.name}"field_type_map={pw.CharField:char_field_factory,}defmy_custom_model_factory(*args,**kwargs)->pw.Model:returnmodel_factory(*args,custom_field_type_map=field_type_map,**kwargs)Want to use with peewee-async?importpeeweeaspwfrompeewee_model_factoryimportmodel_factoryfrompeewee_asyncimportManagermanager=Manager(...)defmy_custom_model_factory(*args,**kwargs)->pw.Model:withmanager.allow_sync():returnmodel_factory(*args,**kwargs)DescriptionA library to create peewee model instances for testing.
The project creation has been inspired bydjango-dynamic-fixtureandpeewee-fake_fixturesprojects.FeaturesRecursevely creating models for foreign fieldsAn option for filling nullable valuesEasy customization if you need to extend or change generation for types of peewee fieldsPossible inconvenienceThe project has no tests.Not all field types of peeweee has factory function in the project. You have to write custom one if you want to use them
Package: peewee-moves
A simple and flexible migration manager forPeewee ORM.Requirementspython >= 3.4, <= 3.6peewee >= 3.0.0InstallationThis package can be installed using pip:pip install peewee-movesUsageHere’s a quick teaser of what you can do with peewee-moves:$exportFLASK_APP=myflaskapp$flaskdbcreateapp.models.CategoryINFO: created migration 0001_create_table_category$flaskdbrevision"do something"INFO: created migration 0002_do_something$flaskdbupgradeINFO: 0001_create_table_category: upgrade
INFO: 0002_do_something: upgrade$flaskdbdowngradeINFO: 0002_do_something: downgrade$flaskdbstatusINFO: 0001_create_table_category: applied
INFO: 0002_do_something: pendingAnd if you’re curious, here’s what0001_create_table_category.pylooks like. A migration was
automatically created based on the definition of the Category model.defupgrade(migrator):withmigrator.create_table('category')astable:table.primary_key('id')table.integer('code',unique=True)table.string('name',max_length=250)defdowngrade(migrator):migrator.drop_table('category')DocumentationCheck out theFull Documentationfor more details.
Package: peewee-mssql
A database driver to add Microsoft SQL Server and Azure support usingpymssqlandFreeTDSin
Peewee and should run on most Unix-like systems, Microsoft Windows and Mac OS X.In it’s current state you should be able to access data and possibly do certain
updates. You will not be able to create tables or introspect existing databases,
so you will have to write your models manually. Offsets will also not work,
since the query compiler will need some significant rewrite to support TSQL
dialect, however limit will work (TOP).InstallationInstall the latest stable release from Pypi:$ pip install peewee-mssqlOr alternatively, select a release or development version from Github and run:$ python setup.py installGetting StartedFor help on installing and configuringFreeTDSI
recommend taking a look at theguidein thepymssqldocumentation.And then you should be able to instantiate a database as below and start
building your models for accessing data:frompeewee_mssqlimportMssqlDatabasedb=MssqlDatabase('MyDatabase',host='host.example.com',user='domain\\username',password='password')If you are using Microsoft SQL Server 2005 you will need to use the legacy
datetime data types, simple passuse_legacy_datetime=Trueto the
database driver when initializing.
Package: peewee_mssqlserv
MS SQL Support forpeewee, lightweight Python ORM.
Based onpyodbc.Inspired bythispost.At this moment it’s in initial stage and supportsCRUDoperations.May be it has more features, but I have not tested them yet.For now only tested with python 2.7 and MS SQL Server 2008.Installationpip install peewee_mssqlservKnown alternative(with declared python3 support):peewee-mssql
Package: peewee-plus
peewee+Various extensions, helpers, and utilities forPeeweeSee theChangelogfor
release history.DocumentationThe documentation for this project is currently a work in progress. Please see the source
code for complete docsInstallingFeaturesFor DevelopersInstallingpeewee+ isavailable on PyPIand can be installed
using Poetry, Pipenv, or Pip:# Using poetrypoetryaddpeewee-plus# Using pipenvpipenvinstallpeewee-plus# Using pippython-mvenvpeeweesourcepeewee/bin/activate
python-mpipinstallpeewee-plusOnce installed, Peewee+ can be imported like below:importpeewee_plusFeaturesConstantsSQLITE_DEFAULT_PRAGMAS- The default pragmas to use with an SQLite database connection,
taken directly from thePeewee docs.SQLITE_DEFAULT_VARIABLE_LIMIT- The maximum number of variables an SQL query can use
when using SQLiteFunctionscalc_batch_size- Helper function for writing backend-agnostic batch queries while
accounting for theSQLite max variable limit.flat_transaction- Decorator function for wrapping callables in a database transaction
without creating nested transactionsClassesPathField- A Peewee database field for storingPathlibobjects, optionally relative to
a runtime value.PrecisionFloatField- A Peewee database field for storing floats while specifying theMySQL precision parametersMandDJSONField- A Peewee database field for storing arbitrary JSON-serializable dataEnumField- A Peewee database field for storing Enums by nameTimedeltaFieldA Peewee database field for natively storingdatetime.timedeltaobjectsFor DevelopersAll project contributors and participants are expected to adhere to theContributor Covenant Code of Conduct, v2(external link).Thedevelbranch has the latest (and potentially unstable) changes. The stable releases
are tracked onGithub,PyPi, and in theChangelog.To report a bug, request a feature, or ask for assistance, pleaseopen an issue on the Github repository.To report a security concern or code of conduct violation, please contact the project
author directly at‌me [at‌] enp dot‎ ‌one.To submit an update, pleasefork the repositoryandopen a pull request.Developing this project requiresPython 3.10or later
andPoetry 1.2or later. GNU Make can
optionally be used to quickly setup a local development environment, but this is not
required.To setup a local development environment:# Clone the repository...# ...over HTTPSgitclonehttps://github.com/enpaul/peewee-plus.git# ...over SSHgitclonegit@github.com:enpaul/peewee-plus.gitcdpeewee-plus/# Create and configure the local dev environmentmakedev# See additional make targetsmakehelp
Package: peewee-rest-query
A rest query request args parser for peewee orm. like no-sql select style.(/?select=id,name,author{*}&id=gte.20&order=id.desc).Installingpip installpeewee-rest-queryTestpython setup.py testUsageUsage:> from peewee_rest_query import PeeweeQueryBuilder, PeeweeSerializer
> class School(Model):
    id = PrimaryKeyField()
    name = CharField(max_length=100)

> class Author(Model):
    id = PrimaryKeyField()
    name = CharField(max_length=50)
    age = IntegerField(default=0)
    school = ForeignKeyField(School)

> class Book(Model):
    id = PrimaryKeyField()
    name = CharField(max_length=255)
    author = ForeignKeyField(Author)

> args = {
        'select': 'id,name,author{id,name,school{*}}',
        'id': 'gte.20',
        'author.id': 'in.10,20,30,40,50',
        'order': 'id.desc',
        'page': 1,
        'limit': 5
    }
> builder = PeeweeQueryBuilder(Book, args)
> builder.select
[<class '__main__.School'>, <peewee.PrimaryKeyField object>, <peewee.CharField object>, <peewee.PrimaryKeyField object>, <peewee.CharField object>]
> build.where
[<peewee.Expression object>, <peewee.Expression object>]
> builder.order
[<peewee.PrimaryKeyField object>]
> builder.paginate
(1, 5)
> builder.build()
<class '__main__.Book'> SELECT "t3"."id", "t3"."name", "t2"."id", "t2"."name", "t1"."id", "t1"."name" FROM "book" AS t1 INNER JOIN "author" AS t2 ON ("t1"."author_id" = "t2"."id") INNER JOIN "school" AS t3 ON ("t2"."school_id" = "t3"."id") WHERE (("t1"."id" >= ?) AND ("t2"."id" IN (?, ?, ?, ?, ?))) ORDER BY "t1"."id" DESC LIMIT 5 OFFSET 0 [20, 10, 20, 30, 40, 50]LicenseMITContactsEmail:huiquanxiong@gmail.com