@@ -24,20 +24,67 @@ def __init__(self, connection, query, state):
2424 self ._last_status = None
2525
2626 def get_query (self ) -> str :
27- """Return the text of the query for this prepared statement."""
27+ """Return the text of the query for this prepared statement.
28+
29+ Example::
30+
31+ stmt = await connection.prepare('SELECT $1::int')
32+ assert stmt.get_query() == "SELECT $1::int"
33+ """
2834 return self ._query
2935
3036 def get_statusmsg (self ) -> str :
31- """Return the status of the executed command."""
37+ """Return the status of the executed command.
38+
39+ Example::
40+
41+ stmt = await connection.prepare('CREATE TABLE mytab (a int)')
42+ await stmt.fetch()
43+ assert stmt.get_statusmsg() == "CREATE TABLE"
44+ """
3245 if self ._last_status is None :
3346 return self ._last_status
3447 return self ._last_status .decode ()
3548
3649 def get_parameters (self ):
50+ """Return a description of statement parameters types.
51+
52+ :return: A tuple of :class:`asyncpg.types.Type`.
53+
54+ Example::
55+
56+ stmt = await connection.prepare('SELECT ($1::int, $2::text)')
57+ print(stmt.get_parameters())
58+
59+ # Will print:
60+ # (Type(oid=23, name='int4', kind='scalar', schema='pg_catalog'),
61+ # Type(oid=25, name='text', kind='scalar', schema='pg_catalog'))
62+ """
3763 self .__check_open ()
3864 return self ._state ._get_parameters ()
3965
4066 def get_attributes (self ):
67+ """Return a description of relation attributes (columns).
68+
69+ :return: A tuple of :class:`asyncpg.types.Attribute`.
70+
71+ Example::
72+
73+ st = await self.con.prepare('''
74+ SELECT typname, typnamespace FROM pg_type
75+ ''')
76+ print(st.get_attributes())
77+
78+ # Will print:
79+ # (Attribute(
80+ # name='typname',
81+ # type=Type(oid=19, name='name', kind='scalar',
82+ # schema='pg_catalog')),
83+ # Attribute(
84+ # name='typnamespace',
85+ # type=Type(oid=26, name='oid', kind='scalar',
86+ # schema='pg_catalog')))
87+ """
4188 self .__check_open ()
4289 return self ._state ._get_attributes ()
4390
0 commit comments