469,270 Members | 1,793 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

Pysqlite text data importing problem

14
hey folks
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 same working directory, i don't know the exact syntax for doing that.

Also can someone help to rename the file name to current date and time rather than user specified name.

Thanks in advance

Expand|Select|Wrap|Line Numbers
  1. #Connecting to Database
  2. import os
  3. import sqlite3
  4. from pysqlite2 import dbapi2 as sqlite
  5. connection = sqlite.connect('Photos.db')
  6. memoryConnection = sqlite.connect(':memory:')
  7. cursor = connection.cursor()
  8.  
  9. #Writing  Data to Database
  10. #Getting data from Text File
  11.  
  12. TXT_FILE = os.getcwd() + "\\Photos.txt"
  13. cursor.execute('CREATE TABLE photos (Name VARCHAR(100) PRIMARY KEY, Date INTEGER, Make VARCHAR(50), Tag VARCHAR(100))') 
  14. cursor.execute('SEPARATOR "|"')
  15. cursor.execute('IMPORT Photos.txt Photos')
  16. connection.commit()
Nov 26 '08 #1
0 1213

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Rob Cowie | last post: by
8 posts views Thread by rdrink | last post: by
14 posts views Thread by Nader Emami | last post: by
5 posts views Thread by =?ISO-8859-1?Q?Gerhard_H=E4ring?= | last post: by
4 posts views Thread by Tilman Kispersky | last post: by
4 posts views Thread by Astley Le Jasper | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.