per page, with , order by , clip by
Results of 1 - 10 of about 18 for cursor (0.010 sec.)
sqlite3 --- SQLite データベース用の DB-API 2.0 インターフェース 14207
sqlite3 --- SQLite データベース用の DB-API 2.0 インターフェース ソースコード: Lib/sqlite3/ SQLite は、軽量なディスク上のデータベースを提供する C ライブラリです。別のサーバプロセスを用意する必要なく、 SQL クエリー言語の非標準的な一種を使用し ... は、あなたは基本的な sqlite3 機能を使用して、 例としてモンティ・パイソンの映画のデータベースを作成します。 あなたがカーソル( cursors )やトランザクション( transactions )を含むデータベースの基本概念を理解していることを前提としています。 まず、新しいデータベ ... への接続を表します。 SQL 文を実行し、SQL クエリから結果を取得するには、データベース・カーソルを使用する必要があります。 con.cursor() を呼び出して Cursor を作成してください: cur = con . cursor () さて、今やデータベース接続とカーソルを取得したので、タイト ... に書き込まれたことを確認します: >>> con . close () >>> new_con = sqlite3 . connect ( "tutorial.db" ) >>> new_cur = new_con . cursor () >>> res = new_cur . execute ( "SELECT title, year FROM movie ORDER BY score DESC" ) >>> title , year = res . fetchone ( ...
https://man.mtool.work/python/3.14/library/sqlite3.html
asyncio での開発 11118
asyncio での開発 非同期プログラミングは、従来の「逐次的」なプログラミングとは異なります。 このページはよくある間違いや落とし穴を列挙し、それらを回避する方法を説明します。 デバッグモード asyncio はデフォルトで本運用モードで実行されます。いっ ... は、非同期ジェネレーターの終了処理が予期しない順序で行われる場合を示しています。 import asyncio work_done = False async def cursor (): try : yield 1 finally : assert work_done async def rows (): global work_done try : yield 2 finally : await asyncio . s ... leep ( 0.1 ) # 非同期の処理を模倣する work_done = True async def main (): async for c in cursor (): async for r in rows (): break break asyncio . run ( main ()) この例の出力は次のようになります。 unhandled exception du ... thout __name__ > () > exception = AssertionError () > Traceback ( most recent call last ): File "example.py" , line 6 , in cursor yield 1 asyncio . exceptions . CancelledError During handling of the above exception , another exception occurred : Traceb ...
https://man.mtool.work/python/3.14/library/asyncio-dev.html
What's New in Python 2.5 9745
What's New in Python 2.5 著者 : A.M. Kuchling この記事では Python 2.5 の新機能を説明します。 Python 2.5 の最終リリースは 2006 年 8 月に予定されており、 PEP 356 にリリース計画が記載されています。 Python 2.5 は 2006 年 9 月 19 日にリリースされ ... 、そのオブジェクトのユーザがこのように書けるようになることです: db_connection = DatabaseConnection () with db_connection as cursor : cursor . execute ( 'insert into ...' ) cursor . execute ( 'delete from ...' ) # ... その他の操作 ... ブロック内のコードが ... nection の基本的なインターフェースを次のように想定します。 class DatabaseConnection : # データベースのインターフェース def cursor ( self ): "新しいトランザクションを開始し、カーソルオブジェクトを返す" def commit ( self ): "現在のトランザクションをコミッ ... で簡単です。 この用途では、作成したカーソルオブジェクトを返すと便利なので、メソッドの戻り値にします。 利用者は with 文に as cursor を追加して、カーソルを変数名に束縛できます。 class DatabaseConnection : ... def __enter__ ( self ): # 新しいトランザクショ ...
https://man.mtool.work/python/3.14/whatsnew/2.5.html
pickle --- Python オブジェクトの直列化 9505
pickle --- Python オブジェクトの直列化 ソースコード: Lib/pickle.py pickle モジュールは、Python オブジェクト構造を直列化・復元するためのバイナリプロトコルを実装しています。 pickle 化 (pickling) とは Python オブジェクトの階層をバイトストリーム ... sistent_load ( self , pid ): # このメソッドは永続的 ID が現れるたびに呼ばれる。 # ここで pid は DBPickler が返したタプル。 cursor = self . connection . cursor () type_tag , key_id = pid if type_tag == "MemoRecord" : # 参照されたレコードをデータベースか ... ら取得して返す。 cursor . execute ( "SELECT * FROM memos WHERE key=?" , ( str ( key_id ),)) key , task = cursor . fetchone () return MemoRecord ( ... def main (): import io import pprint # データベースを初期化し、データを挿入する。 conn = sqlite3 . connect ( ":memory:" ) cursor = conn . cursor () cursor . execute ( "CREATE TABLE memos(key INTEGER PRIMARY KEY, task TEXT)" ) tasks = ( 'give food to f ...
https://man.mtool.work/python/3.14/library/pickle.html
unittest.mock --- 入門 9042
unittest.mock --- 入門 Added in version 3.3. Mock を使う モックでメソッドにパッチを当てる 一般的な Mock の使い方の中には次のものがあります: メソッドにパッチを当てる オブジェクトに対するメソッド呼び出しを記録する システムの他の部分からメソッ ... モックに属性を設定したかったら、普通に設定するだけです: >>> mock = Mock () >>> mock . x = 3 >>> mock . x 3 mock.connection.cursor().execute("SELECT 1") のような複雑なケースでモックを使いたい場合もあります。この呼出があるリストを返すようにしたい場合、こ ... ければなりません。 call を使って "chained call" 内の呼び出しを構成して、 assert で使うことができます: >>> mock = Mock () >>> cursor = mock . connection . cursor . return_value >>> cursor . execute . return_value = [ 'foo' ] >>> mock . connection . cursor ... () . execute ( "SELECT 1" ) ['foo'] >>> expected = call . connection . cursor () . execute ( "SELECT 1" ) . call_list () >>> mock . mock_calls [call.connection.cursor(), call.connection.cursor().execu ...
https://man.mtool.work/python/3.14/library/unittest.mock-examples.html
What's New in Python 2.6 9042
What's New in Python 2.6 著者 : A.M. Kuchling (amk at amk.ca) この記事では、2008 年 10 月 1 日にリリースされた Python 2.6 の新機能を説明します。 リリース日程は PEP 361 に記載されています。 Python 2.6 の主要なテーマは、言語を大幅に再設計する ... 、そのオブジェクトのユーザがこのように書けるようになることです: db_connection = DatabaseConnection () with db_connection as cursor : cursor . execute ( 'insert into ...' ) cursor . execute ( 'delete from ...' ) # ... その他の操作 ... ブロック内のコードが ... nection の基本的なインターフェースを次のように想定します。 class DatabaseConnection : # データベースのインターフェース def cursor ( self ): "新しいトランザクションを開始し、カーソルオブジェクトを返す" def commit ( self ): "現在のトランザクションをコミッ ... で簡単です。 この用途では、作成したカーソルオブジェクトを返すと便利なので、メソッドの戻り値にします。 利用者は with 文に as cursor を追加して、カーソルを変数名に束縛できます。 class DatabaseConnection : ... def __enter__ ( self ): # 新しいトランザクショ ...
https://man.mtool.work/python/3.14/whatsnew/2.6.html
curses --- 文字セル表示のターミナル処理 8253
curses --- 文字セル表示のターミナル処理 ソースコード: Lib/curses curses モジュールは、移植可能な高度な端末処理の事実上の標準である curses ライブラリへのインターフェースを提供します。 curses が最も広く用いられているのは Unix 環境ですが、Wind ... , attr ] ) window. insch ( y , x , ch [ , attr ] ) Insert character ch with attributes attr before the character under the cursor, or at (y, x) if specified. All characters to the right of the cursor are shifted one position right, with the rightmost c ... haracter on the line being lost. The cursor position does not change (after moving to y , x , if specified). window. insdelln ( nlines ) 指定されたウィンドウの現在の行 ... str , n [ , attr ] ) Insert a character string (as many characters as will fit on the line) before the character under the cursor, up to n characters. If n is negative, the entire string is inserted. All characters to the right of the cursor are shifte ...
https://man.mtool.work/python/3.14/library/curses.html
What's New In Python 3.1 8133
What's New In Python 3.1 著者 : Raymond Hettinger この記事では Python 3.0 と比較した Python 3.1 の新機能を説明します。 Python 3.1 は 2009 年 6 月 27 日にリリースされました。 PEP 372: 順序付き辞書 通常の Python 辞書は、 key/value ペアを不定の ... ドリスト、あるいはユーザ入力などです: >>> query = input () SELECT region, dept, count(*) FROM main GROUPBY region, dept >>> cursor . execute ( query ) >>> query_fields = [ desc [ 0 ] for desc in cursor . description ] >>> UserQuery = namedtuple ( 'UserQ ... uery' , query_fields , rename = True ) >>> pprint . pprint ([ UserQuery ( * row ) for row in cursor ]) [UserQuery(region='South', dept='Shipping', _2=185), UserQuery(region='North', dept='Accounting', _2=37), UserQuery(reg ...
https://man.mtool.work/python/3.14/whatsnew/3.1.html
collections --- コンテナデータ型 8012
collections --- コンテナデータ型 ソースコード: Lib/collections/__init__.py このモジュールは、汎用の Python 組み込みコンテナ dict , list , set , および tuple に代わる、特殊なコンテナデータ型を実装しています。 namedtuple() 名前付きフィールドを ... "employees.csv" , "rb" ))): print ( emp . name , emp . title ) import sqlite3 conn = sqlite3 . connect ( '/companydata' ) cursor = conn . cursor () cursor . execute ( 'SELECT name, age, title, department, paygrade FROM employees' ) for emp in map ( Em ... ployeeRecord . _make , cursor . fetchall ()): print ( emp . name , emp . title ) タプルから継承したメソッドに加えて、名前付きタプルは3つの追加メソッドと ...
https://man.mtool.work/python/3.14/library/collections.html
データの永続化 8012
データの永続化 この章で解説されるモジュール群は Python データをディスクに永続的な形式で保存します。モジュール pickle とモジュール marshal は多くの Python データ型をバイト列に変換し、バイト列から再生成します。様々な DBM 関連モジュールはハッシ ... ータベース用の DB-API 2.0 インターフェース チュートリアル リファレンス モジュール関数 モジュール定数 Connection オブジェクト Cursor オブジェクト Row オブジェクト Blob オブジェクト PrepareProtocol オブジェクト 例外 SQLite と Python の型 デフォルトの適合関 ...
https://man.mtool.work/python/3.14/library/persistence.html
PREV 1 2 NEXT