Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a decorator for creating table via class-style. #823

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

YogiLiu
Copy link

@YogiLiu YogiLiu commented Dec 23, 2024

This feature add a decorator to create table via class-style, it's friendly to type hint.

from pypika import table_class, Table, Field, Query

@table_class('customers')
class Customer(Table):
    id = Field('id')
    first_name = Field('fname')
    last_name = Field('lname')
    phone = Field('phone')

q = Query.from_(Customer).select(Customer.id, Customer.first_name, Customer.last_name, Customer.phone)

The decorator's parameters are same as Table.__init__.

@YogiLiu YogiLiu requested a review from a team as a code owner December 23, 2024 12:11
@YogiLiu YogiLiu closed this Dec 23, 2024
@YogiLiu YogiLiu reopened this Dec 23, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant