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
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
Code:
#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()