TecUtils

Various utilities for database and config files use
Download

TecUtils Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Other/Proprietary Li...
  • Publisher Name:
  • Gabriel Martin del Campo y Eternod

TecUtils Tags


TecUtils Description

Various utilities for database and config files use TecUtils is a software that provides various utilities to accelerate development of programs design to use MySQL as a database and substitute the use of global variables.TecUtils contains the following modules:- mydb- envvarmydb:Requires: mysql-pythonProvides: There are three functions that take care the database interaction: - GetRecordset(sHost,sUser,sPwd,sDB,sSQL) - GetData(sHost,sUser,sPwd,sDB,sSQL) - ExecuteSQL(sHost,sUser,sPwd,sDB,sSQL)::import TecUtils.mydbmyHost = "localhost"myUser = "root"myPwd = "password"myDB = "test"TecUtils.mydb.ExecuteSQL(myHost, myUser, myPwd, myDB, "INSERT INTO animal (name, category) VALUES " + \ ('snake', 'reptile'), ('frog', 'amphibian'), ('tuna', 'fish'), ('racoon', 'mammal'), ('lizard', 'reptile')")sql="SELECT name FROM animal WHERE category='reptile'"TecUtils.mydb.GetRecordset(myHost, myUser, myPwd, myDB,sql)thistype='fish'sql="SELECT name FROM animal WHERE category='%s'" % thistypeTecUtils.mydb.GetData(myHost, myUser, myPwd, myDB,sql)::envvar:Provides: Reads a file containing = and loads in a container, so you can use container.var getVarFromFile(filename,container)Use:::db = getVarFromFile('config/db.cfg','db')::Examples:If use the two modules provides a way to use a configuration file to access de database:::# this is the config file:# db.cfgHOST = 'localhost'USER = 'root'PWD = 'ahivoy'DB = 'facturae'::and use it in a program:::import TecUtilsTecUtils.envvar.getVarFromFile('db.cfg',db)data = TecUtils.mydb.GetRecordset(db.HOST,db.USER,db.PWD,db.DB,"SELECT * FROM animal")for animal in data: print animal:: Requirements: · Python


TecUtils Related Software