[pysqlite] pysqlite importing problem
Waseem Bourgi <alwaseem307ster-/[email protected]> Fri, 28 Nov 2008 08:42:24 -0800 (PST)
| Newsgroups | gmane.comp.python.db.pysqlite.user |
|---|---|
| Message-ID | <[email protected]> |
Hi sir:
i am facing this problem in my following codes where i am trying to
create a database using pysqlite and load data from text file where
data is arranged in this form "Birthday2|12/5/2008|HTC|this is my
birthday"
but i could connect to the database, create it into my current working
directory but i can't load the data from my text file in the same working
directory, i don't know the exact syntax for doing that. i appricate your help.
Thanks in advance
Codes
Expand|Select|Wrap|Line Numbers #Connecting to Database
import os
import sqlite3
from pysqlite2 import dbapi2 as sqlite
connection = sqlite.connect('Photos.db')
memoryConnection = sqlite.connect(':memory:')
cursor = connection.cursor()
#Writing Data to Database
#Getting data from Text File
TXT_FILE = os.getcwd() + "\\Photos.txt"
cursor.execute('CREATE TABLE photos (Name VARCHAR(100) PRIMARY KEY, Date INTEGER, Make VARCHAR(50), Tag VARCHAR(100))')
cursor.execute('SEPARATOR "|"')
cursor.execute('IMPORT Photos.txt Photos')
connection.commit()
_______________________________________________
list-pysqlite mailing list
list-pysqlite-FR6EJeJVuqdwc357pe9rcyQmJico6nz3epZhswDD4dQ@public.gmane.org
http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite