Skip to content

Commit de683c0

Browse files
committed
some more wrappers
1 parent c1a8ffe commit de683c0

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

ydb/_grpc/grpcwrapper/ydb_query.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,47 @@ def from_proto(msg: ydb_query_pb2.BeginTransactionResponse) -> "BeginTransaction
115115
return BeginTransactionResponse(
116116
status=ServerStatus(msg.status, msg.issues),
117117
tx_meta=TransactionMeta.from_proto(msg.tx_meta),
118-
)
118+
)
119+
120+
@dataclass
121+
class QueryContent(IFromPublic, IToProto):
122+
text: str
123+
syntax: Optional[str]
124+
125+
@staticmethod
126+
def from_public(query: str) -> "QueryContent":
127+
return QueryContent(text=query)
128+
129+
def to_proto(self) -> ydb_query_pb2.QueryContent:
130+
return ydb_query_pb2.QueryContent(text=self.text, syntax=self.syntax)
131+
132+
133+
@dataclass
134+
class TransactionControl(IToProto):
135+
begin_tx: Optional[TransactionSettings]
136+
commit_tx: Optional[bool]
137+
tx_id: Optional[str]
138+
139+
def to_proto(self) -> ydb_query_pb2.TransactionControl:
140+
if self.tx_id:
141+
return ydb_query_pb2.TransactionControl(
142+
tx_id=self.tx_id,
143+
commit_tx=self.commit_tx,
144+
)
145+
return ydb_query_pb2.TransactionControl(
146+
begin_tx=self.begin_tx,
147+
commit_tx=self.commit_tx
148+
)
149+
150+
151+
@dataclass
152+
class ExecuteQueryRequest:
153+
exec_mode: Optional[str]
154+
concurrent_result_sets: bool = False
155+
parameters: Optional[dict]
156+
query_content: QueryContent
157+
session_id: str
158+
stats_mode: Optional[str]
159+
tx_control: TransactionControl
160+
161+

0 commit comments

Comments
 (0)