Had 5 mins waiting for a conference call so knocked this bit of Python
up. No debugging, comments or testing (other than one run on a test
db)

import sqlite3
import tkinter
import tkinter.filedialog

root = tkinter.Tk()
root.withdraw()

fileName = tkinter.filedialog.askopenfilename(parent=root,
title='Select the SQLite database')
DB = sqlite3.connect(fileName)

print ('Processing ' + fileName)

tables = DB.execute("select * from sqlite_master where type like 'table'")

for tablerow in tables:
    tableName = tablerow[2]
    print ("tableName = " + tableName)
    columns = DB.execute("pragma table_info (" + tableName + ")")
    for colrow in columns:
        colName = colrow[1]
        colType = colrow[2]
        print ("colName = " + colName)
        DB.execute("UPDATE " + tableName + " SET " + colName + " =
REPLACE(" + colName + ", 'paul', 'sandy')")

DB.commit()
Paul
www.sandersonforensics.com
skype: r3scue193
twitter: @sandersonforens
Tel +44 (0)1326 572786
http://sandersonforensics.com/forum/content.php?195-SQLite-Forensic-Toolkit
-Forensic Toolkit for SQLite
http://sandersonforensics.com/forum/content.php?168-Reconnoitre - VSC
processing made easy



On 4 December 2014 at 12:31, Paul Sanderson
<sandersonforens...@gmail.com> wrote:
> As above I use
>
> pragma table_info tablename
>
> then you can loop through each row and check the type column to see if
> it is text
> Paul
> www.sandersonforensics.com
> skype: r3scue193
> twitter: @sandersonforens
> Tel +44 (0)1326 572786
> http://sandersonforensics.com/forum/content.php?195-SQLite-Forensic-Toolkit
> -Forensic Toolkit for SQLite
> http://sandersonforensics.com/forum/content.php?168-Reconnoitre - VSC
> processing made easy
>
>
>
> On 4 December 2014 at 11:57, Dominique Devienne <ddevie...@gmail.com> wrote:
>> On Thu, Dec 4, 2014 at 11:45 AM, Baruch Burstein <bmburst...@gmail.com>
>> wrote:
>>
>>> On Thu, Dec 4, 2014 at 12:18 PM, Paul Sanderson <
>>> > If you are a coder then it is a relatively straight forward process
>>> > Loop through each table
>>> >    Loop through each column
>>>
>>> This is the part I am having trouble with. I can loop through tables using
>>> sqlite3_master, but how do I loop through columns? Parse the schema?
>>
>>
>> http://www.sqlite.org/pragma.html#pragma_table_info  --DD
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to