Hi all,

this is my first project using Sqlite3 so I might have done something silly 
along the way. 
I can not run queries for the last columns of my tables. I either get only the 
very last row or nothing where there should be hundreds of entries which match 
the query. 

Here is what I did:

I read network data from a csv file into Sqlite using the following code in 
Python and transformed them into unicode.
Where edges and nodes are represented as a list which contains a list of the 
node and its attributes.
One sample node entry: 
[(u'1480', u'Z_Avi', u'2', u'3', u'1', u'4', u'99', u'3', u'99', u'11', 
u'Kaufmann')]


to enter edges:


    conn = sqlite3.connect("test.db")
    c = conn.cursor()

    for i in range(len(edges)):

        edge1 = [(
                    edges[i][0],
                    edges[i][1],
                    edges[i][2],
                    edges[i][3],
                    edges[i][4],
                    edges[i][5],
                    edges[i][6],
                    edges[i][7],
                    edges[i][8],
                    edges[i][9],
                    edges[i][10],
                    edges[i][11],
                    edges[i][12],
                    edges[i][13],
                    edges[i][14],
                    edges[i][15],
                    edges[i][16],
                    edges[i][17],
                )]

        i = 0

        c.executemany("INSERT INTO edges 
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", edge1)
        conn.commit()
    print "inserted records: edges"

    conn.close()




and then to enter nodes:




    conn = sqlite3.connect("test.db")
    c = conn.cursor()
    for i in range(len(nodes)):

        node1 = [(
                    nodes[i][0],
                    nodes[i][1],
                    nodes[i][2],
                    nodes[i][3],
                    nodes[i][4],
                    nodes[i][5],
                    nodes[i][6],
                    nodes[i][7],
                    nodes[i][8],
                    nodes[i][9],
                    nodes[i][10],
                )]
        i = 0

        c.executemany("INSERT INTO nodes VALUES(?,?,?,?,?,?,?,?,?,?,?)", node1)
        conn.commit()

    conn.close()


This works ok and I am able to import everything into the Firefox SQlite 
Manager and Gephi. However I only get one result if I run the query
SELECT * FROM nodes WHERE Netzwerk="Kaufmann"

Any thoughts and tips on this are much appreciated.

Best, Marten





--
Dr. Marten Düring
Digital Humanities Researcher
Centre Virtuel de la Connaissance sur l’Europe (CVCE) 
www.cvce.eu / www.cubrikproject.eu

Personal website, Historical Network Research

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to