PDA

View Full Version : [SOLVED] Source code for SQLite Python as instruction in FCM Special Python 1?



tridephysique
August 1st, 2013, 03:34 AM
Hi everybody,
I am learning Pyhton myself following instruction in FCM Special Series Python. At the end of Part 7 of Volume 1, there is website to download source code www.thedesignatedgeek.com (http://www.thedesignatedgeek.com), but the site is about healthcare, I cannot find any thing about Infomatics or Programing.
How can I get the source code?
Thanks.

oldfred
August 1st, 2013, 06:07 AM
the source code is in the article and can be copied & pasted into a python file. Not quite as easy as downloading it, but it works.

I use Geany, but do not use APSW. And I like to use sqliteman to review sqltables after I create them or other tasks directly. I use that to also test my sql code before copying into a python script.

Copy & paste into a python script. I copied sql from pdf and created this for just one table. You can then add the other tables. and queries.


#! /usr/bin/env python
# -*- coding: utf-8 -*-

import sys, threading, Queue, os
import sqlite3

def dbi(filename):
create = not os.path.exists(filename)
dbi = sqlite3.connect(filename)
return dbi


def makeTable(tblname, sql):
db = dbi(tblname)
cursor = db.cursor()
cursor.execute(sql)


sql = 'CREATE TABLE IF NOT EXISTS Recipes (pkiD INTEGER PRIMARY KEY, name TEXT, servings TEXT, source TEXT)'
makeTable("cookbook1.db", sql)

gordintoronto
August 1st, 2013, 06:42 PM
The web site is a .net, not a .com.