def populate_db(conn):
    authors = ([author] for author in AUTHORS_BOOKS.keys())
    cur = conn.cursor()
    cur.executemany(author_insert, authors)
    
    for author in AUTHORS_BOOKS.keys():
        params = ([book, author] for book in AUTHORS_BOOKS[author])
        cur.executemany(book_insert, params)
コード例 #2
0
def populate_db(conn):
    authors = ([author] for author in AUTHORS_BOOKS.keys())
    cur = conn.cursor()
    cur.executemany(author_insert, authors)

    for author in AUTHORS_BOOKS.keys():
        params = ([book, author] for book in AUTHORS_BOOKS[author])
        cur.executemany(book_insert, params)
コード例 #3
0
def populate_db(conn):
    authors = ([author] for author in AUTHORS_BOOKS.keys())
    cur = conn.cursor()
    logging.debug("connected")
    cur.executemany(author_insert, authors)

    for author in AUTHORS_BOOKS.keys():
        params = ([book, author] for book in AUTHORS_BOOKS[author])
        cur.executemany(book_insert, params)

    logging.debug("changes made")
コード例 #4
0
ファイル: threaded.py プロジェクト: marklap/Py300
def populate_db(conn):
    authors = ([author] for author in AUTHORS_BOOKS.keys())
    cur = conn.cursor()
    logging.debug("connected")
    cur.executemany(author_insert, authors)
    
    for author in AUTHORS_BOOKS.keys():
        params = ([book, author] for book in AUTHORS_BOOKS[author])
        cur.executemany(book_insert, params)
    
    logging.debug("changes made")
コード例 #5
0
def show_books(conn):
    query = book_query
    show_query_results(conn, query)


if __name__ == '__main__':
    if DB_IS_NEW:
        print "Database does not yet exist, please import `createdb` first"
        sys.exit(1)

    with sqlite3.connect(DB_FILENAME) as conn1:
        print "\nOn conn1, before insert:"
        show_authors(conn1)

        authors = ([author] for author in AUTHORS_BOOKS.keys())
        cur = conn1.cursor()
        cur.executemany(author_insert, authors)
        print "\nOn conn1, after insert:"
        show_authors(conn1)

        with sqlite3.connect(DB_FILENAME) as conn2:
            print "\nOn conn2, before commit:"
            show_authors(conn2)

            conn1.commit()
            print "\nOn conn2, after commit:"
            show_authors(conn2)