cardinal_pythonlib.dbfunc
Original code copyright (C) 2009-2022 Rudolf Cardinal (rudolf@pobox.com).
This file is part of cardinal_pythonlib.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Functions to operate with the raw Python database API.
See https://www.python.org/dev/peps/pep-0249/.
- cardinal_pythonlib.dbfunc.dictfetchall(cursor: Pep249DatabaseCursorType) List[Dict[str, Any]] [source]
Return all rows from a cursor as a list of
OrderedDict
objects.- Parameters:
cursor¶ – the cursor
- Returns:
a list (one item per row) of
OrderedDict
objects whose key are column names and whose values are the row values
- cardinal_pythonlib.dbfunc.dictfetchone(cursor: Pep249DatabaseCursorType) Dict[str, Any] | None [source]
Return the next row from a cursor as an
OrderedDict
, orNone
.
- cardinal_pythonlib.dbfunc.fetchallfirstvalues(cursor: Pep249DatabaseCursorType) List[Any] [source]
Return a list of the first value in each row.
- cardinal_pythonlib.dbfunc.gendicts(cursor: Pep249DatabaseCursorType, arraysize: int = 1000) Generator[Dict[str, Any], None, None] [source]
Generate all rows from a cursor as
OrderedDict
objects.
- cardinal_pythonlib.dbfunc.genfirstvalues(cursor: Pep249DatabaseCursorType, arraysize: int = 1000) Generator[Any, None, None] [source]
Generate the first value in each row.
- cardinal_pythonlib.dbfunc.genrows(cursor: Pep249DatabaseCursorType, arraysize: int = 1000) Generator[List[Any], None, None] [source]
Generate all rows from a cursor.
- cardinal_pythonlib.dbfunc.get_fieldnames_from_cursor(cursor: Pep249DatabaseCursorType) List[str] [source]
Get a list of fieldnames from an executed cursor.