コード例 #1
0
ファイル: sqlite_test_03.py プロジェクト: smohaorg/xc
__author__= "Luis C. Pérez Tato (LCPT)"
__copyright__= "Copyright 2014, LCPT"
__license__= "GPL"
__version__= "3.0"
__email__= "*****@*****.**"

dbName= "/tmp/pilares.db"
import os
os.system("rm -f " + dbName)
sqlite_macros.SQLTcreaDBase(dbName)

conn= sqlite.connect(dbName)
cur= conn.cursor()
cur.execute("create table test3 ( num integer, name string );")
cur.execute("create table test4 ( A integer, B double );")
sqlite_macros.SQLTborraTabla(dbName,"test3")
sqlite_macros.SQLTborraTabla(dbName,"test4")
e1= sqlite_macros.SQLTexisteTabla(dbName,"test3")
e2= sqlite_macros.SQLTexisteTabla(dbName,"test4")



from misc_utils import log_messages as lmsg
fname= os.path.basename(__file__)
if (not e1) & (not e2):
  print('test '+fname+': ok.')
else:
  lmsg.error(fname+' ERROR.')

os.system("rm -f /tmp/pilares.db")
コード例 #2
0
conn = sqlite.connect(dbName)
conn.row_factory = sqlite.Row
otra = conn.cursor()
cur = conn.cursor()
cur.execute("select distinct ACCION from " + tbName)
rows = cur.fetchall()
for r in rows:
    i += 1
    idAccion = r['ACCION']
    sqlStr = "select * from " + tbName + " where ACCION = '" + idAccion + "';"
    otra.execute(sqlStr)
    for row in otra:
        j += 1

e1 = sqlite_macros.SQLTexisteTabla(dbName, tbName)

ratio1 = abs(i - 6) / 6  # 6 actions
ratio2 = abs(j / 6 - 144)  # 144 elements
''' 
print("i= ",i)
print("ratio1= ",ratio1)
print("j= ",j)
print("ratio2= ",ratio2)
   '''

import os
from misc_utils import log_messages as lmsg
fname = os.path.basename(__file__)
if (abs(ratio1) < 1e-15) & (abs(ratio2) < 1e-15) & e1:
    print("test ", fname, ": ok.")