ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
AtlTriggerDBCopy.SQLiteInserter Class Reference
Collaboration diagram for AtlTriggerDBCopy.SQLiteInserter:

Public Member Functions

def __init__ (self, filename=None)
 
def commit (self)
 
def insert (self, statement, data)
 
def insertBulk (self, statement, data)
 
def createSchema (self, creationFileName)
 

Public Attributes

 filename
 
 connection
 
 activeTransaction
 
 insCountInTrans
 
 maxInsertsPerTransaction
 
 cursor
 

Detailed Description

Definition at line 53 of file AtlTriggerDBCopy.py.

Constructor & Destructor Documentation

◆ __init__()

def AtlTriggerDBCopy.SQLiteInserter.__init__ (   self,
  filename = None 
)

Definition at line 55 of file AtlTriggerDBCopy.py.

55  def __init__(self, filename = None):
56  self.filename = filename
57  self.connection = None
58  self.activeTransaction = False
59  self.insCountInTrans = 0
60  self.maxInsertsPerTransaction = 1000
61  if self.filename is None:
62  print("Not connected to an output file, will print the insert commands instead")
63  import os
64  if filename and os.path.exists(filename):
65  print(f"Target file {filename} exists already, will abort in order to prevent overwriting")
66  raise RuntimeError("Target file already exists")
67  if self.filename is not None:
68  self.connection = sqlite3.connect(self.filename)
69  self.cursor = self.connection.cursor()

Member Function Documentation

◆ commit()

def AtlTriggerDBCopy.SQLiteInserter.commit (   self)

Definition at line 70 of file AtlTriggerDBCopy.py.

70  def commit(self):
71  if self.activeTransaction:
72  self.cursor.execute('COMMIT')
73  self.activeTransaction = False
74  self.insCountInTrans = 0
75 

◆ createSchema()

def AtlTriggerDBCopy.SQLiteInserter.createSchema (   self,
  creationFileName 
)

Definition at line 93 of file AtlTriggerDBCopy.py.

93  def createSchema(self, creationFileName):
94  if self.connection is None:
95  return
96  with open(creationFileName) as fh:
97  print("Creating sqlite db %s from %s" % (self.filename, creationFileName) )
98  self.cursor.executescript( fh.read() )
99 
100 
101 # class to handle the extraction of schema and data on the oracle side

◆ insert()

def AtlTriggerDBCopy.SQLiteInserter.insert (   self,
  statement,
  data 
)

Definition at line 76 of file AtlTriggerDBCopy.py.

76  def insert(self, statement, data):
77  if self.connection is None:
78  return
79  if not self.activeTransaction:
80  self.cursor.execute('BEGIN TRANSACTION')
81  self.activeTransaction = True
82  self.cursor.execute(statement, data)
83  self.insCountInTrans += 1
84  if self.insCountInTrans==self.maxInsertsPerTransaction:
85  self.commit()
86 

◆ insertBulk()

def AtlTriggerDBCopy.SQLiteInserter.insertBulk (   self,
  statement,
  data 
)

Definition at line 87 of file AtlTriggerDBCopy.py.

87  def insertBulk(self, statement, data):
88  if self.connection is None:
89  return
90  self.cursor.executemany(statement, iter(data))
91  self.connection.commit()
92 

Member Data Documentation

◆ activeTransaction

AtlTriggerDBCopy.SQLiteInserter.activeTransaction

Definition at line 58 of file AtlTriggerDBCopy.py.

◆ connection

AtlTriggerDBCopy.SQLiteInserter.connection

Definition at line 57 of file AtlTriggerDBCopy.py.

◆ cursor

AtlTriggerDBCopy.SQLiteInserter.cursor

Definition at line 69 of file AtlTriggerDBCopy.py.

◆ filename

AtlTriggerDBCopy.SQLiteInserter.filename

Definition at line 56 of file AtlTriggerDBCopy.py.

◆ insCountInTrans

AtlTriggerDBCopy.SQLiteInserter.insCountInTrans

Definition at line 59 of file AtlTriggerDBCopy.py.

◆ maxInsertsPerTransaction

AtlTriggerDBCopy.SQLiteInserter.maxInsertsPerTransaction

Definition at line 60 of file AtlTriggerDBCopy.py.


The documentation for this class was generated from the following file:
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::open
@ open
Definition: BinningType.h:40
query_example.cursor
cursor
Definition: query_example.py:21
calibdata.commit
bool commit
Definition: calibdata.py:832