First post.
Please have a look at this . I just cant figure out how to insert the values into the table "safely" as per code block 3 on the python docs link below. I just dont undertsand how to define the value of the symbols from a csv file.
I need to add all the values of the csv into the created table.
http://docs.python.o...ry/sqlite3.html
import csv
import sqlite3
#Create the database#
connection = sqlite3.connect('//home/mgrobler/database/working/pricelist')
cursor = connection.cursor()
cursor.execute('DROP TABLE prices')
cursor.execute('CREATE TABLE prices ( Code text, Description text, Price integer) ')
connection.commit
#parse csv and read it into the database#
creader = csv.reader(open('//home/mgrobler/database/src/pricelist.csv', 'rb'), delimiter=',', quotechar='|')
t = (creader,)
for t in creader:
cursor.execute('INSERT INTO prices VALUES (?,?,?)', t )
Im no pro so ive been stuck with this for days . If someone can help me out by explaining the symbol method within the context of my code above it would be greatly appreciated.

New Topic/Question
Reply




MultiQuote





|