matsutus matsutus - 1 year ago 37
SQL Question

Python Sqlite inserting strings of numbers one at a time

So I have made a python script, which collects the creation-, and expirationdates of domainnames from a list of whois -results.

Now I would like to insert these dates into the table, and the hoped result would be


But what the script inserts into the database is


I've tried converting the datatypes in the database to anything I can imagine, and that didn't do the trick.

def date():

o = open('outputfile.rtf')

for line in o:

line = line.replace('\n', '') //Just removing some breaks

if 'created' in line:

line = line.replace('created: ', '')

creationdate = str(line)

print (creationdate)
c.executemany("INSERT INTO pvm (creationdate) VALUES (?)", creationdate)



Edit: Can you try to reformat creationdate to be:

creationdate = ['24.1.2005', '22.3.2002', '20.3.2006', '11.12.2013', '22.2.2005', '19.7.2005']

Note: In addition to the above - matsutus updated his code to the following line:

c.execute("INSERT INTO pvm (creationdate) VALUES (?)", (line,)) 

And the combination of both lines solved the problem.


Turning the data into an array, and then making sure the insert execute is

c.execute("INSERT INTO pvm (luomispvm) VALUES (?)", (line,))

instead of

c.execute("INSERT INTO pvm (luomispvm) VALUES (?)", line)

Fixed it!