Definition at line 53 of file AtlTriggerDBCopy.py.
◆ __init__()
def AtlTriggerDBCopy.SQLiteInserter.__init__ |
( |
|
self, |
|
|
|
filename = None |
|
) |
| |
Definition at line 55 of file AtlTriggerDBCopy.py.
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")
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()
◆ commit()
def AtlTriggerDBCopy.SQLiteInserter.commit |
( |
|
self | ) |
|
Definition at line 70 of file AtlTriggerDBCopy.py.
71 if self.activeTransaction:
73 self.activeTransaction =
False
74 self.insCountInTrans = 0
◆ 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:
96 with open(creationFileName)
as fh:
97 print(
"Creating sqlite db %s from %s" % (self.filename, creationFileName) )
98 self.cursor.executescript( fh.read() )
◆ 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:
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:
◆ 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:
90 self.cursor.executemany(statement, iter(data))
◆ activeTransaction
AtlTriggerDBCopy.SQLiteInserter.activeTransaction |
◆ connection
AtlTriggerDBCopy.SQLiteInserter.connection |
◆ cursor
AtlTriggerDBCopy.SQLiteInserter.cursor |
◆ filename
AtlTriggerDBCopy.SQLiteInserter.filename |
◆ insCountInTrans
AtlTriggerDBCopy.SQLiteInserter.insCountInTrans |
◆ maxInsertsPerTransaction
AtlTriggerDBCopy.SQLiteInserter.maxInsertsPerTransaction |
The documentation for this class was generated from the following file: