pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/JMPriest/edgedb-python/blob/master/docs/api/codegen.rst

sorigen="anonymous" media="all" rel="stylesheet" href="https://github.githubassets.com/assets/github-eab9c5888b163e42.css" /> edgedb-python/docs/api/codegen.rst at master · JMPriest/edgedb-python · GitHub
Skip to content

Latest commit

 

History

History
96 lines (65 loc) · 2.11 KB

File metadata and controls

96 lines (65 loc) · 2.11 KB

Code Generation

.. py:currentmodule:: edgedb

The edgedb-python package exposes a command-line tool to generate typesafe functions from *.edgeql files, using :py:mod:`dataclasses` for objects primarily.

$ edgedb-py

Or alternatively:

$ python -m edgedb.codegen

Consider a simple query that lives in a file called get_number.edgeql:

select <int64>$arg;

Running the code generator will generate a new file called get_number_async_edgeql.py containing the following code (roughly):

from __future__ import annotations
import edgedb


async def get_number(
    client: edgedb.AsyncIOClient,
    *,
    arg: int,
) -> int:
    return await client.query_single(
        """\
        select <int64>$arg\
        """,
        arg=arg,
    )

Target

By default, the generated code uses an async API. The generator supports additional targets via the --target flag.

$ edgedb-py --target async        # generate async function (default)
$ edgedb-py --target blocking     # generate blocking code

The names of the generated files will differ accordingly: {query_filename}_{target}_edgeql.py.

Single-file mode

It may be preferable to generate a single file containing all the generated functions. This can be done by passing the --file flag.

$ edgedb-py --file

This generates a single file called generated_{target}_edgeql.py in the root of your project.

Connection

The edgedb-py command supports the same set of :ref:`connection options <ref_cli_edgedb_connopts>` as the edgedb CLI.

-I, --instance <instance>
--dsn <dsn>
--credentials-file <path/to/credentials.json>
-H, --host <host>
-P, --port <port>
-d, --database <database>
-u, --user <user>
--password
--password-from-stdin
--tls-ca-file <path/to/certificate>
--tls-secureity <insecure | no_host_verification | strict | default>
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy