
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Python MysqlCommand is a MySql query builder that enables using keyword parameters. Inspired by the MysqlCommand class by Mysql for ASP.net
Use the package manager pip to install Python MysqlCommand
pip install mysqlcommand
import mysql.connector
from mysqlcommand import MysqlCommand
dbcon = mysql.connector.connect(
host='{host}',
user='{username}',
passwd='{password}'
)
dbcom = MysqlCommand('select * from {table}', dbcon)
dbcom.execute_reader()
while dbcom.read():
dbcom.data['{columnName}']
dbcom.commandstr = 'select * from {table} where {columnName} = ?columnValue'
dbcom.parameters.add('?columnValue', '{value}')
dbcom.execute_reader()
while dbcom.read():
dbcom.data['{columnName}']
dbcom.commandstr = 'select * from {table} where {columnName} in ?columnValue'
dbcom.parameters.add('?columnValue', ['{value}', '{value2}', '{value3}'])
dbcom.execute_reader()
while dbcom.read():
dbcom.data['{columnName}']
Useful when just needing a boolean or count
dbcom.commandstr = 'select count(*) from {table}'
table_count = dbcom.execute_scalar()
# For database manipulation to ensure data changes are saved automatically
dbcom.set_autocommit(True)
dbcom.commandstr = 'update {table} set '{columnName}' = ?columnNewValue where '{columnName}' = ?columnOldValue';
dbcom.parameters.add('?columnOldValue', 3)
dbcom.parameters.add('?columnNewValue', 5)
dbcom.execute_non_query()
# To commit database changes without autocommit
dbcom.commit()
new_row = {
'{columnName}': 1
}
insert_id = dbcom.insert('{table}', new_row)
new_rows = [{
'{columnName}': 2
},
{
'{columnName}': 3
}]
recordsInserted = dbcom.insert('{table}', new_rows)
dbcom.parameters.set('?columnOldValue', 5)
dbcom.parameters.setadd('?columnOldValue', 5)
dbcom.parameters.clear()
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
FAQs
Mysql query builder
We found that mysqlcommand demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.