บทความ

กำลังแสดงโพสต์จาก เมษายน, 2018

python3 : เชื่อมต่อ mongoDb

step 1 ติดตั้งด้วยคำสั่ง py -m pip install pymongo step2 ลองรัน Code ดังนี้ (ใช้ฐานข้อมูลจากตัวอย่างก่อนหน้านี้) from pymongo import MongoClient # pprint library is used to make the output look more pretty from pprint import pprint # connect to MongoDB, change the << MONGODB URL >> to reflect your own connection string client = MongoClient('mongodb://localhost:27017') db=client.NetFlick # Issue the serverStatus command and print the results #serverStatusResult=db.command("serverStatus") result = db.movies.find() #print(serverStatusResult) for r in result: print (r)

mongoDB: การติดตั้งและใช้งาน shell เบื้องต้น

กำลังเขียน.. .. MongoDB v6 ไม่มี shell ติดมาให้แล้ว  ต้องไป download มาติดตั้งเพิ่มเอาเอง (แตกไฟล์แล้วคัดลอก bin folder ไปผนวกทับของเดิม .. .

Python3 : ใส่สีให้ Text Mode Application

รูปภาพ
ใช้ colorama ตัวอย่าง Code Code ตัวอย่าง from colorama import init,Fore, Back, Style init(autoreset=True)# reset to default after end print() command #from termcolor import colored #ไม่ทำงานบน windows 10 #from colorama import #print (colored("Teerasak",'red')) print(Fore.RED + 'Teerasak') print(Back.GREEN + 'some red text') print('AfterGreen') #print(Back.GREEN + 'and with a green background') #print(Style.DIM + 'and in dim text') #print(Style.RESET_ALL) print('back to normal now') ผลลัพธ์ หรือจะใช้คู่กับ termcolor module ก็ย่อมได้ ผลลัพธ์ เขียนโดย ครูชลิตา จูมสีมา

python3: wxPython การสลับหลายๆ panel บน frame

http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/

Python3 : อ่าน เขียน ไฟล์ excel 2010 / CSV

MS Excel 2010 https://openpyxl.readthedocs.io/en/stable/ การติดตั้ง ใช้คำสั่ง...     py -m pip install openpyxl CSV (standard module ไม่ต้องติดตั้งเพิ่ม) https://docs.python.org/3/library/csv.html

Python3 : เชื่อมต่อกับฐานข้อมูล

Db มีหลายยี่ห้อ แต่ละยี่ห้อมี api ของตัวเอง python เลยมี Python DB Api ของตัวเองเป็นตัวกลาง(PEP249) DatabaseModule ที่ทำตาม PythonDbApi จะมี 3 properties -apilevel -threadsafety -paramstyle ต้องมีการ connect เพื่อสร้าง session curror object ใน python ใช้สำหรับการ excute query และทดสอบผลลัพธ์ ใช้ query แล้ว อย่าลืม commit() Type ชนิดต่างๆ เพื่อใช้ให้ตรงกับ Database เช่น STRING,NUMBER,DATETIME Python 2.5 มี PySQLite ที่ผนวกรวม SQLite มาด้วย เว้นแต่ compile python เอาเอง ### Example Code จากหนังสือ  Beginning Python  From Novice to Professional,  Second Edition import sqlite3 def convert(value):     if value.startswith('~'):         return value.strip('~')     if not value:         value = '0'     return float(value) conn = sqlite3.connect('food.db') curs = conn.cursor() curs.execute('''     CREATE TABLE food (     id TEXT PRIMARY KEY,     de...

โปรแกรมจัดการ SQLite (firefox plugin เลิกพัฒนาแล้ว)

https://sqlitestudio.pl/index.rvt

windows 10: เปิด Terminal จาก current folder

ทำตามนี้ https://www.windowscentral.com/add-open-command-window-here-back-context-menu-windows-10 การใช้งาน ให้กด Shift + คลิกขาว อีกวิธีคือ พิมพ์คำสั่ง cmd หรือ powershell มันใน address bar ของ windown explorer เลย