pwtools.sql.SQLEntry¶
- class pwtools.sql.SQLEntry(sqlval=None, sqltype=None, fileval=None, key=None)[source]¶
Bases:
object
Represent an entry in a SQLite database. An entry is one single value of one column and record (record = row).
This class is ment to be used in parameter studies where a lot of parameters are vaired (e.g. in pw.x input files) and entered in a SQLite database.
There is the possibility that the entry has a slightly different value in the db and in the actual input file. See fileval.
- __init__(sqlval=None, sqltype=None, fileval=None, key=None)[source]¶
- Parameters:
sqlval (Any Python type (str, unicode, float, integer, ...)) – The value of the entry which is entered into the database.
sqltype ({str, None}, optional) –
A string (not case sentitive) which determines the sqlite type of the entry: ‘integer’, ‘real’, ‘null’, … If None then automatic type detection will be attempted. Only default types are supported, see notes below. This is needed to create a sqlite table like in:
create table calc (foo integer, bar real)
fileval ({None, <anything>}, optional) –
If not None, then this is the value of the entry that it has in another context (actually used in the input file). If None, then fileval = val. Example: K_POINTS in pw.x input file:
sqlval: '2 2 2 0 0 0' fileval: 'K_POINTS automatic\n2 2 2 0 0 0'
key (optional, {None, str}, optional) –
An optional key. This key should refer to the column name in the database table, as in:
% create table calc (key1 sqltype1, key2 sqltype2, ...)
For example:
% create table calc (idx integer, ecutwfc float, ...)
Notes
SQLite types from the Python docs of sqlite3:
Python type SQLite type ----------- ----------- None NULL int INTEGER long INTEGER float REAL str (UTF8-encoded) TEXT unicode TEXT buffer BLOB
Methods