Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Various utilities for database and config files use. Text to Pdf converter

Project Description

tecutils provides various utilities to accelerate development
of programs design to use MySQL as a database and substitute
the use of global variables.
Also includes a standalone module to tranform a text file to pdf.

tecutils contains the following modules:

- mydb
- envvar
- simplecrypt
- txt2pdf


mysql-python (sudo apt-get install python-mysqldb)

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)::

from tecutils.mydb import ExecuteSQL, GetData, GetRecordset

myHost = "localhost"
myUser = "root"
myPwd = "password"
myDB = "test"

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'"
GetRecordset(myHost, myUser, myPwd, myDB,sql)

sql="SELECT name FROM animal WHERE category='%s'" % thistype
GetData(myHost, myUser, myPwd, myDB,sql)


Reads a file containing <var>=<value> and loads in a container, so you can use container.var



from tecutils import getVarFromFile
db = getVarFromFile('config/db.cfg','db')


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 = 'password'
DB = 'test'

and use it in a program::

from tecutils.envvar import getVarFromFile
from tecutils.mydb import GetRecordset


data = GetRecordset(db.HOST,db.USER,db.PWD,db.DB,"SELECT * FROM animal")
for animal in data:
print animal[0]


Many thanks to the Dabo team: Ed Leafe and Paul McNett (
for this simple utility to "obscure" passwords so casual browsing on the database
connection info doesn't show the real one.


from tecutils.simplecrypt import simplecrypt
pwd = 'foobar'
crypt = SimpleCrypt()
pwd = crypt.encrypt(pwd)

or using the example from envvars::

crypt = SimpleCrypt()
db.PWD = crypt.decrypt(db.PWD)


requires reportlab and pyPDF for normal use
for windows printing requires win32api or ghostscript and ghostview

Usage: [options] text_file
The name of the outfile is the name on the text_file with pdf extension.

-h, --help show this help message and exit
-c COPIES, --copies=COPIES
number of copies, only valid with -p option
-g print through ghostprint, only valid with -w option
-m use half letter as size of output, default letter
--output=OUTPUT use specific output file name
-p, --print print file after converting
--printer=PRINTER printer to send file, default: send to default printer
-w use win32api to send file to print, only valid with -p
Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
TecUtils-0.4.0.linux-i686.tar.gz (11.1 kB) Copy SHA256 Checksum SHA256 any Dumb Binary Aug 16, 2012
TecUtils-0.4.0.tar.gz (8.1 kB) Copy SHA256 Checksum SHA256 Source Aug 16, 2012

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting