Thanks for your reply, Miguel.

Curiously, my sbmSUBMISSIONS table is empty. I checked with a colleague and his 
is too. Do you know why this might be? We're both working on SimpleStore, if 
that helps.

Huw

From: Miguel Martín [mailto:[email protected]]
Sent: 08 October 2013 13:33
To: Morris, Huw (STFC,RAL,RALSP)
Cc: [email protected]
Subject: Re: Querying invenio database

Hi,

Just read your email while I was coding something very similar. I am running 
0.99.1 and you can get what you need by querying sbmSUBMISSIONS table.

mysql> desc sbmSUBMISSIONS;

+-----------+-------------+------+-----+---------------------+-------+

| Field     | Type        | Null | Key | Default             | Extra |

+-----------+-------------+------+-----+---------------------+-------+

| email     | varchar(50) | NO   |     |                     |       |

| doctype   | varchar(10) | NO   |     |                     |       |

| action    | varchar(10) | NO   |     |                     |       |

| status    | varchar(10) | NO   |     |                     |       |

| id        | varchar(30) | NO   |     |                     |       |

| reference | varchar(40) | NO   |     |                     |       |

| cd        | datetime    | NO   |     | 0000-00-00 00:00:00 |       |

| md        | datetime    | NO   |     | 0000-00-00 00:00:00 |       |

+-----------+-------------+------+-----+---------------------+-------+

8 rows in set (0.00 sec)


A sample function to return the last 'cuantos' submissions:

def consultaUltimosEnvios(cuantos):

    # consulta la lista de ultimos envios (SBI)

    from invenio.dbquery import run_sql

    query = "SELECT id, doctype, email, md, reference FROM sbmSUBMISSIONS WHERE 
action='SBI' AND status='finished' ORDER BY md DESC LIMIT %s" %cuantos

    res = run_sql(query)

    for i in res:

        print i[3],"\t[",i[0],"]\tdoctype:",i[1],"\tRef:",i[4],"\tPor",i[2]


Hope this helps to get you started :-)

Cheers!

Miguel

---
Miguel Martín
www.leccionespracticas.com<http://www.leccionespracticas.com>


El 08/10/13 14:23, [email protected]<mailto:[email protected]> escribió:
Hi,

I'm trying to write an SQL query to show all the documents submitted by a user 
(not necessarily the currently logged in user.) What I actually want is to show 
the total disk usage of each user, but if I can just get a list of the 
documents submitted, given either a user id or email, I should be able to take 
it from there. Is there documentation out there to describe all the tables in 
the invenio db?

Thanks in advance,
Huw


--
Scanned by iCritical.



-- 
Scanned by iCritical.

Reply via email to