Skip to main content
========
tecutils
========

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

mydb
====

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

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

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)

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


envvar
======

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

getVarFromFile(filename,container)

Use::

from tecutils import getVarFromFile
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 = 'password'
DB = 'test'


and use it in a program::

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

getVarFromFile('db.cfg',db)

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


simplecrypt
===========

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

Use::

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)


txt2pdf
=======

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

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

Options:
-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
option

Release files for TecUtils 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for TecUtils 0.4.0
File Size Uploaded
TecUtils-0.4.0.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for TecUtils 0.4.0
File Interpreter ABI Platform
TecUtils-0.4.0.linux-i686.tar.gz Details

Total release size: 19.2 kB

Release files / TecUtils-0.4.0.tar.gz

Download URL TecUtils-0.4.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cfe72b0f2b131f366639dd2d70aad3b9404038782bf46f72281aa37b57dda56f
BLAKE2b-256 checksum
How to use checksums
96a5068694a7bfaa28aa35311f995340a49e794eafe7babb3286e8a1427479b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / TecUtils-0.4.0.linux-i686.tar.gz

Download URL TecUtils-0.4.0.linux-i686.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2cb7f5b63844a8f613a917cbc710c6a3bfc5bea71720d13f5a75ab41eccbffcd
BLAKE2b-256 checksum
How to use checksums
e3ba68711989291db0791e2fea02e9ffcadf15bf0b95f92d5296304c2cf49e98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page