Skip to content

Issues connecting to PostgreSQL with Peewee #733

Answered by CodePunk-
CodePunk- asked this question in Q&A
Discussion options

You must be logged in to vote

For those running into the same issue, utilize the @pyscript_executor and move the class models inside the function. Whether this is the right solutions, I do not know. I'm not a python nor a Pyscript expert but it works for my needs. Hope it helps others and thanks to the developers of Pyscript. I find this custom integration easier than some other solutions.

from peewee import Model, CharField, PostgresqlDatabase

# Database configuration
DATABASE_CONFIG = {
    'host': 'timescaledb',
    'database': 'database_name',
    'user': 'user01',
    'password': 'password01',
    'port': 5432
}

# Create database instance
database = PostgresqlDatabase(**DATABASE_CONFIG)

@pyscript_executor
def c…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@CodePunk-
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by CodePunk-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants