HOME/Articles/

pil example Image01 img db (snippet)

Article Outline

Python pil example 'Image01 img db'

Functions in program:

  • def read_tbl(conn, table):
  • def open_db():

Modules used in program:

  • import sqlite3 as db

python Image01 img db

Python pil example: Image01 img db

import sqlite3 as db

def open_db():
    try:
        conn = db.connect('imgstat.db',)
        print('Open image database')
        return conn

    except db.Error as e:

        print('DB connection error: ', e)

    return None


def read_tbl(conn, table):
    sql = 'select a. exifvalue, a.cnt from (select exiftag, exifvalue, count(exiftag) as cnt from picdata where exiftag = "EXIF FocalLength" group by exiftag,exifvalue) as a'
    cur = conn.cursor()
    cur.execute(sql)

    rows = cur.fetchall()

    return rows