TecUtils

Software Screenshot:
TecUtils
Software Details:
Version: 0.4.0
Upload Date: 20 Feb 15
Distribution Type: Freeware
Downloads: 59

Rating: 4.0/5 (Total Votes: 1)

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
- envvar

mydb:

Requires:
    mysql-python

Provides:
    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.mydb

myHost = "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'" % thistype
TecUtils.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.cfg
HOST = 'localhost'
USER = 'root'
PWD = 'ahivoy'
DB = 'facturae'

::


and use it in a program:

::
import TecUtils


TecUtils.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[0]

::

Requirements:

  • Python

Similar Software

MyJSQLView
MyJSQLView

20 Feb 15

doppler
doppler

20 Feb 15

FreeTDS
FreeTDS

11 May 15

Comments to TecUtils

Comments not found
Add Comment
Turn on images!