import horsql
import pandas as pd
import datetime
from horsql.operators import Between, Like
from horsql import operators as o
from horsql.query_builder import And, Or


db = horsql.connect("rps", "localhost", 5432, "dev", "dev", echo=True)


users = [
    dict(user_id=4, email="asda11", birthday=None),
    dict(user_id=2, email="kkkkkkkkkkk", birthday="2023-09-09"),
    dict(user_id=3, email="asda22", birthday="1992-09-19"),
]

df = pd.DataFrame(users)

db.public.users.update(
    df, conflict_columns=["user_id"], update_columns=["birthday", "email"]
)

db.public.users.order_by("user_id").get()


db.public.users.order_by("user_id").get(
    ["user_id", "user_name"],
    where=Or(
        Or(
            And(email="asdas", user_name="peidei"),
            user_id=o.EqualsOrLessThan(2),
        ),
        And(user_id=o.EqualsOrGreaterThan(5), user_name="user10"),
    ),
)

db.public.users.order_by("user_id").get(
    ["user_id", "user_name"], user_id=o.EqualsOrGreaterThan(5), user_name="user10"
)


def f(*args, column=None, **kwargs):
    print(column, args, kwargs)


"""
SELECT
user_id, user_name
FROM
public.users
WHERE (user_id in (1, 2) and email like '%%@%%')
"""
