SQLamarr
The stand-alone ultra-fast simulation option for the LHCb experiment
EditEventStore.py
1 # (c) Copyright 2022 CERN for the benefit of the LHCb Collaboration.
2 #
3 # This software is distributed under the terms of the GNU General Public
4 # Licence version 3 (GPL Version 3), copied verbatim in the file "LICENCE".
5 #
6 # In applying this licence, CERN does not waive the privileges and immunities
7 # granted to it by virtue of its status as an Intergovernmental Organization
8 # or submit itself to any jurisdiction.
9 import ctypes
10 from ctypes import POINTER
11 from SQLamarr import clib, c_TransformerPtr
12 
13 from SQLamarr.db_functions import SQLite3DB
14 
15 from typing import List, Union
16 
17 clib.new_EditEventStore.argtypes = (
18  ctypes.c_void_p, # void *db,
19  ctypes.c_char_p, # const char* semicolon_separated_queries,
20  )
21 
22 clib.new_EditEventStore.restype = c_TransformerPtr
23 
25  """
26  Execute a transaction with multiple custom queries without
27  returning any output.
28 
29  Refer to SQLamarr::EditEventStore for implementation details.
30  """
31  def __init__ (self, db: SQLite3DB, queries: Union[str,List[str]]):
32  """
33  Configure a Transformer to edit the schema of the EventStore
34 
35  @param db: An open database connection.
36  @param queries: One or more queries to be processed in single transaction
37  """
38  if isinstance(queries, str):
39  queries = [queries]
40 
41  self._self_self = clib.new_EditEventStore(
42  db.get(),
43  ";".join(queries).encode('ascii')
44  )
45 
46  def __del__(self):
47  """@private: Release the bound class instance"""
48  clib.del_Transformer(self._self_self)
49 
50  @property
51  def raw_pointer(self):
52  """@private: Return the raw pointer to the algorithm."""
53  return self._self_self
54 
55 
56 
57 
Execute a transaction with multiple custom queries without returning any output.
def __init__(self, SQLite3DB db, Union[str, List[str]] queries)
Configure a Transformer to edit the schema of the EventStore.