Making sqlite3 inserts using python variable - variables

so I have a sqlite3 table with the following schema:
('number','name','prename','id','number_a','location_num','team')
Im wondering how to be able to fill some of those with content of a python variable.Number,id,number_a and team dont have to be filled.So basically, I have 3 python variable
thename='franco'
theprename='john'
thelocation_num=2
So I want to be able to insert at the right place the content of the python variable.I tried this so far:
cur.execute("INSERT INTO mytable('number','name','prename','id','number_a','location_num','team') VALUES('','?','?','','','?','')",(thename,),(theprename,),(thelocation_num,))
However it doesnt work.I dont know how to do that.
thank you

You can use
cur.execute("""INSERT INTO mytable
('number','name','prename','id','number_a','location_num','team')
VALUES('',?,?,'','',?,'')""",
(thename, theprename, thelocation_num))
If autocommit is not enabled, you also need to call connection.commit() in order to write the changes to disk.

Related

Using minecrafts plugin Skript - How to make a loop, that checks, if player goes in WorldGuard region?

So, I wanna make a loop, that checks, if player goes in WorldGuard region. I don't have any specific details, just i wanna know how to do it.
This is how my code looks like:
set {_rg::*} to %region at player%
loop {_rg::*}:
if "%loop-value%" contains "fail1_1"
execute console command "tp %player% -425.5 9.87500 2299.767 0.0 50.0"
if "%loop-value%" contains "fail1_2":
execute console command "tp %player% -425.5 10 2304.5 0.0 50.0"
Im not really an expert, but i tried to look it up. So, nothing really happened, there were no errors, but it didn't work as i expected (if you fall into region, you get teleported to a location)
I think it is most likely that your Skript installation is broken, your code should give multiple errors that make you aware why your code is not working. Try the latest version of Skript that is available on GitHub.
set {_rg::*} to %region at player%
If you are not working inside a text, you can't use the percentage signs, these are made to interpolate the given variable to text. Skript would create a working {_rg:*} list variable without the percentage signs.
You could use the percentage signs if you wanted to message at which regions the player is:
message "Regions: %region at player%" to player
if "%loop-value%" contains "fail1_1"
A colon is missing at the end of this statement, which should lead to errors while parsing.
execute console command "tp %player% -425.5 9.87500 2299.767 0.0 50.0"
While you can execute commands to teleport players using Skript, you can also teleport players without executing console commands. The reason for this is that Skript will not check if the command is going to work.
Instead, you can use the location function to create a new location and teleport the player to it.
teleport player to location(-425.5, 9.87500, 2299.767, player's world, 0.0, 50.0)

Robotframework - how to fix this deprecated functionality ${row.find_elements_by_tag_name('td')}

At somepoint there was an update to some functionality and now the following doesnt work on robotframework anymore
${row.find_elements_by_tag_name('td')}
I cant seem to fix this and cant find much support
I believe the new way is done by using by.TAG_NAME() or something like that
For context im getting the table rows (tr) and storing it in a list, for each tr I want to get the table divisions (td) so I can create a list of each tr but have access to the td within.
This is done so I can check a csv file matches the table when exported
Below is the section of code
#{severity_list}= Create List
FOR ${page} IN RANGE 99999
#{rows}= Get Alarms Table Rows
FOR ${row} IN #{rows}
#{elements}= Set Variable ${row.find_elements_by_tag_name('td')}
# Train Severity List
#{train_severity}= Create List
Append To List ${train_severity} ${elements[2].text}
Append To List ${train_severity} ${elements[3].text}
# Get Severity value
Append To List ${severity_list} ${train_severity}
END
I believe the new way is done by using by.TAG_NAME() or something like that
ERROR Message:Resolving variable '${row.find_elements_by_tag_name('td')}' failed:
AttributeError: 'WebElement' object has no attribute 'find_elements_by_tag_name'

Move SAP package to top level

We have a subpackage thet we want to move up to the top level, so that it doesn't have any superpackage anymore.
The 'change' dialog for superpackage does not allow an empty value:
Is there another way to do this, or does the package need to be deleted and recreated?
There does not appear to be a UI function to remove that assignment. However, you could try to do this programmatically: use CL_PACKAGE_FACTORY to load the package (you'll get an instance of IF_PACKAGE), then call SET_SUPER_PACKAGE_NAME. Haven't tried it myself, though.
Looks like it's stored in table TDEVC field PARENTCL. So you can try (at your own risk) to edit the record and remove superpackage from there.

Maximo - Adding elements to a CustomMboSet using scripting

Is it possible to add to a CustomMboSet in Maximo using scripting? I am writing a custom application using a custom object called TIMESHEET. As part of the application I am writing a (Jython) script that needs to dynamically build up an MboSet (a set of TIMESHEETs). The code retrieves an existing CustomMboSet and attempts to add elements to it. It works when using an out of box MboSet, but when I try to run the same code on a custom MboSet it does not seem to work. No error is thrown, but code below the offending line is not run.
In other words, this works (LABTRANS is an out of box MBO):
myMboSet = mbo.getMboSet("LABTRANS")
newMbo = myMboSet.add()
# Set attributes on newMbo, everything is happy
But this does not (TIMESHEET is a custom MBO):
myMboSet = mbo.getMboSet("TIMESHEET")
newMbo = myMboSet.add()
# Code does not execute after the above line
Anyone have any insight as to why I am seeing this behavior? Does the Maximo scripting framework simply not support the dynamic building up of CustomMboSets? Any help is appreciated. Thanks.
You need to make sure that the relationship exists between the Current MBO and the Custom MBO in the database configuration otherwise it will not work.
Alternatively you can use the following code to create an new mboSet on the fly:
timeSheetMboSet = mxServer.getMboSet("TIMESHEET", userInfo)
mbo.getMboSet(RELATIONSHIPNAME).
LABTRANS and TIMESHEET must be the relationship names to the object in auto script.
If you want to get/add records in any object, use
mxServer.getMboSet(OBJECTNAME, userInfo)
A bit more explanation. You can create your own custom relationship from within your automation script. The trick is to make sure it's not already existing. That's why I use a dollar sign for mine.
variable = mbo.getMboSet(tempRelationshipName,Object,where clause)
previousPhaseSet = mbo.getMboSet("$wophasetranstemp1", "exitdate is null")

How to modify {userinfoserial} via Pascal?

If I want to modify {userinfoserial} variable at the end of installation (user inputs only part of the serial during the installation process).
How can I modify {userinfoserial} through Pascal?
I do not want to create new variable, but modify existing.
I have tried several ways, but with no luck - unfortunately WizardUserInfoSerial is unknown identifier where WizardDirValue is OK what is strange to me...
If that is not possible, then I will create new variable.