プログラミング

シンプルに使い方を紹介

2017-06-17から1日間の記事一覧

【Python】SQLiteで構文中に変数を挿入する

テストプログラム # -*- coding:utf-8 -*- import sqlite3 conn = sqlite3.connect("test.db") # テーブルの作成 conn.execute("create table tbl_name(id, name)") # データの挿入 conn.execute("insert into tbl_name values( ?, ? )", [ 1, "Sato" ]) # …

【Python】SQLiteでデータの読み込み

import sqlite3 conn = sqlite3.connect("test.db") cursor = conn.cursor() cursor.execute("select * from tbl_name where num >= 3") result = cursor.fetchall() for row in result: msg = msg + str(row[0]) + str(row[1]) + "\n" cursor.close() conn.…

【Python】LINE APIでユーザIDを取得する

body = request.get_data(as_text=True) receive_json = json.loads(body) userId = receive_json["events"][0]["source"]["userId"]

【SQLite】基本操作

データベースに接続 $ sqlite3 test.db データベースの確認 sqlite > .database テーブルの確認 sqlite > .table テーブルにある値の確認 sqlite > select * from tbl_name;

【Python】【SQLite3】基本的な利用方法

データベースの作成 import sqlite3 conn = sqlite3.connect("test.db") conn.close() テーブルの作成 conn.execute("create table tbl_name(num, val)") テーブルに値を挿入 conn.execute("insert into tbl_name values( '1', 'val1' )") conn.execute("ins…