Skip to content

Can't add schema name to query in fetch function #201

New issue

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

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

Already on GitHub? Sign in to your account

Closed
sihcpro opened this issue Mar 11, 2020 · 0 comments
Closed

Can't add schema name to query in fetch function #201

sihcpro opened this issue Mar 11, 2020 · 0 comments

Comments

@sihcpro
Copy link

sihcpro commented Mar 11, 2020

I got a problem when I try to add schema name to the query. My code:

dbpool = app.config["pool"]
async with dbpool.acquire() as conn:
    sql = """
        SELECT _id, name, address
        FROM "{schema}".account
        WHERE _id IN (
            SELECT account_id
            FROM "{schema}"."account-message"
            WHERE message_id IN (
                SELECT _id
                FROM "{schema}".message
                WHERE sender = $1
            )
        );
    """.format(
        schema=config.SCHEMA
    )
    resp = await conn.fetch(sql, address)

and it work very well, except for the lint:security give me a security issue:

Issue: [B608:hardcoded_sql_expressions] Possible SQL injection vector through string-based query construction.

And when I try to pass my schema name to conn.fetch() function but it didn't work. Can you help me?

@sihcpro sihcpro closed this as completed Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant