Пример #1
0
def draw_imge(p, rec_numero):
    global y
    global x
    global columnax
    global columnay

    x = 0
    y = 0
    columnax = 0
    columnay = 0

    os.environ['INFORMIXSERVER'] = 'ol_urbano'
    conn = informixdb.connect('scm30@ol_urbano',
                              user='******',
                              password='******')
    cursor = conn.cursor(rowformat=informixdb.ROW_AS_DICT)
    #query_string = "call scm_reclamo_impresion_img(6406);"
    query_string = "call scm_reclamo_impresion_img(" + rec_numero + ");"
    cursor.execute(query_string)
    imagenes = cursor.fetchall()

    vi = 0
    index = 0
    for value in imagenes:
        vi += 1
        index += 1
        if index == 1:
            p.showPage()
            p.translate(0, 297 * mm)

        draw_imgtif(p, index, value)
        index = 0 if (index % etiquetas == 0) else index

    cursor.close()
Пример #2
0
    def __init__(self, id_solicitud):
        self.id_solicitud = id_solicitud
        '''
        Parameters of connection - Informix
        '''
        os.environ['INFORMIXSERVER'] = 'ol_urbano'
        conn = informixdb.connect('scm30@ol_urbano',
                                  user='******',
                                  password='******')
        self.cursor = conn.cursor(rowformat=informixdb.ROW_AS_DICT)
        self.rs = self.getDataSolicitud()
        self.rs = self.rs[0]

        self.estado = int(self.rs['estado'])

        self.ftp_host_origen = self.rs['ftp_server']
        self.ftp_user_origen = self.rs['ftp_user']
        self.ftp_pass_origen = self.rs['ftp_clave']
        self.ftp_path_origen = self.rs['ftp_path']
        self.ftp_file = self.rs['ftp_file']

        self.ftp_host_destino = self.rs['ftp_server_d']
        self.ftp_user_destino = self.rs['ftp_user_d']
        self.ftp_pass_destino = self.rs['ftp_clave_d']
        self.ftp_path_destino = self.rs['ftp_path_txt']

        self.getFileTmp()
        self.validar_file()
Пример #3
0
    def connect(self):
        dbname = self.config['dbname']
        dbuser = self.config['dbuser']
        dbpass = self.config['dbpass']

        #print "creds" + str( self.config )
        conn = informixdb.connect(dbname, user=dbuser, password=dbpass)
        conn.autocommit = True
        self.conn = conn
        '''
Пример #4
0
 def connct_ifx(self):
   try:
       conn = None
       conn = informixdb.connect(self.Database+'@'+self.Server,self.Username,self.Password)
       if not conn:
           raise Exception("Failed to connect via SQL to " + self.Database+'@'+self.Server,self.Username,self.Password)
       else:
           print("connect !!!!")
           return conn
   except:
       pass
Пример #5
0
	def initEngine(self):
		self.engine = create_engine	(
							self.protocol, 
							creator=lambda: informixdb.connect	(
													self.database, 
													self.user, 
													self.password
												), 
							echo=False, 
							poolclass=SingletonThreadPool
						)
Пример #6
0
 def _new_cursor(self):
     try:
         if self.conn is None:
             print("reconnect to SQL server ...")
             self.conn = informixdb.connect(self.__Database + '@' + self.__Server, self.__Username, self.__Password)
             if self.conn is None:
                 raise Exception("Failed to connect via SQL to informixdb")
         c = self.conn.cursor()
         if c is None:
             raise Exception("Failed to get a cursor on SQL connect")
         return c
     except Exception as e:
         logging.exception(e)
         return None
Пример #7
0
	def connect(cls):
		Database = 'd_1460371498316150'
		if globals().get('debug'):
			Database = 'd_1460371579579196'
			Server = 'localhost'
			Username = '******'
			Password = '******'
		else:
			Server = 'ifxserver1'
			Username = '******'
			Password = '******'

		#if MysqlModel.conn is not None:
		#	return MysqlModel.conn
		try:
			if globals().get('debug'):
				MysqlModel.conn = informixdb.connect(Server, Username, Password, Database)
			else:
				MysqlModel.conn = informixdb.connect(Database + '@' + Server, Username, Password)
		except:
			MysqlModel.conn = None
		if MysqlModel.conn is None:
			raise Exception("Failed to connect via SQL")
		return MysqlModel.conn
Пример #8
0
 def __init__(self):
     self.__startTime = datetime.now().strftime("%Y%m%d%H%M")
     self.__Database = 'd_1460371357365469'
     self.__Server = 'ifxserver1'
     self.__Username = '******'
     self.__Password = '******'
     self.__sellerName = 'seller'
     self.__inventoryName = 'inventory'
     self.__customerName = 'customer'
     self.__userTabName = 'user_info'
     self.__orderName = 'single_order'
     self.__currentName = 'current'
     self.__detailName = 'detail'
     # configure error logging
     logging.basicConfig(level=logging.DEBUG,
                         format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                         datefmt='%a, %d %b %Y %H:%M:%S',
                         filename='log/' + self.__startTime + 'request.log',
                         filemode='w')
     # sql statement object
     self.stat = sql_statement.SqlStatement()
     # informix sql server connection
     self.conn = None
     self.conn = informixdb.connect(self.__Database + '@' + self.__Server, self.__Username, self.__Password)
     if not self.conn:
         raise Exception("Failed to connect via SQL to informixdb")
     else:
         print("connected to database " + self.__Database)
         logging.debug(msg='connected to database')
     # big const
     self.__userAttr = ('user_name', 'user_addr', 'user_tel', 'user_privilege', 'user_id')
     self.__inventoryAttr = (
         'inventory_name', 'inventory_desc', 'picture_url', 'inventory_price', ' inventory_quantity', 'category_id',
         'seller_id', 'inventory_id'
     )
     self.__orderAttr = ('comment_seller', 'deliver_id', 'customer_id', 'payment_status', 'total_price', 'order_date', 'payment_date', 'last_update', 'seller_id', 'order_id')
     self.__orderAttr_mask = ('comment_seller', 'deliver_id', 'customer_id', 'payment_status','total_price', 'order_date', None, None, 'seller_id', 'order_id')
     self.__detailAttr = ( 'inventory_id', 'inventory_name', 'quantity', 'comment_inventory')
     self.__customerAttr = ('user_name', 'user_addr', 'user_tel', 'user_privilege', 'user_id', 'customer_name', 'customer_email')
     self.__payment_status_dict = {1: 'unpaid', 2: 'paid', 3: 'shipping', 4: 'delivered', 5: 'refunded', 6: 'cancelled'}
     self.__sql_last_serial = 'SELECT DBINFO(\'SQLCA.SQLERRD1\') FROM systables WHERE tabname = \'systables\''
Пример #9
0
def test_SQL():

    try:
        cur = conn = None
        #connect
        conn = informixdb.connect(Database+'@'+Server,Username,Password)
        if not conn:
            raise Exception("Failed to connect via SQL to " + dbservername)
        else:
            print("connect !!!!")
        #get cursor
        cur = conn.cursor()
        #query count of testtable(if not exists,created)
        cur.execute("create table if not exists testtable(id int, str char(50))")
        cur.execute("select count(*) from testtable")
        a = cur.fetchall()
        print("Count is :")
        print(a[0][0])

        #insert a record into testtable
        cur.execute("insert into testtable values(1,'hello')")
        print("inserted a record!")

        #query count of testtable again
        cur.execute("select count(*) from testtable")
        a = cur.fetchall()
        print("Count is :")
        print(a[0][0])

        #commit
        conn.commit()

    finally:
        if cur:
            cur.close()
        if conn:
            conn.close()
Пример #10
0
pdfmetrics.registerFont(TTFont('xcalibriBd', path + 'fonts/calibrib.ttf'))
pdfmetrics.registerFont(TTFont('xcalibriIt', path + 'fonts/calibrii.ttf'))
pdfmetrics.registerFont(TTFont('xcalibriBI', path + 'fonts/calibriz.ttf'))

registerFontFamily('xcalibri',normal='xcalibri',bold='xcalibriBd',italic='xcalibriIt',boldItalic='xcalibriBI')

styles = getSampleStyleSheet()
styles.add(ParagraphStyle(name = 'Justify', fontName = 'xcalibri', fontSize = 6, leading = 5, alignment = TA_JUSTIFY, bulletFontName = 'xcalibri', borderWidth = 5))#, borderColor = '#FFFFFF'#fondo de la celda

styleN = styles['Justify']

'''
Parámetros de conexión
'''
os.environ['INFORMIXSERVER'] = 'ol_urbano'
conn = informixdb.connect('scm30@ol_urbano', user='******', password='******')
cursor = conn.cursor(rowformat = informixdb.ROW_AS_DICT)
#query_string = "call spv_impresioncargo_sp1("+params[0]+","+params[2]+","+params[1]+");"
query_string = "call scm_gestor_ftp_pu_print_label("+params[0]+",1);"

cursor.execute(query_string)
rows = cursor.fetchall()

width = 210
height = 297
#salto = height / 16
#espacio = width / 4 
columnax = 0
columnay = 0
y = 0
x = 0
Пример #11
0
	def __init__(self):
		print 'instantiated new Informix client'
		self.conn = informixdb.connect('cars@hewey',user='******',password='******')
		self.cur = self.conn.cursor(rowformat = informixdb.ROW_AS_DICT)	
Пример #12
0
def main():
server = os.getenv("INFORMIXSERVER")
database = None
where = None
numDelPerTransaction = 10
sleepSeconds = 1
verbose = False

# parse command line arguments
try:
opts, args = getopt.getopt(sys.argv[1:], "S:d:w:n:s:v?")
except:
usage(server)
sys.exit(2)

for opt, val in opts:
if opt == "-S":
server = val
if opt == "-d":
database = val
if opt == "-w":
where = val
if opt == "-n":
numDelPerTransaction = int(val)
if opt == "-s":
sleepSeconds = int(val)
if opt == "-v":
verbose = True
if opt == "-?":
usage(server)
sys.exit()

# if the required arguments were not passed display the usage and exit
if (numDelPerTransaction < 1) or (sleepSeconds < 0) or (where is None):
usage(server)
sys.exit()

# sql to select the primary key fields (pkcol1 and pkcol2) from table1 that
# meet the user defined where clause
sqlSelect = """
select
pkcol1,
pkcol2
from
table1
where
%s
""" % (where, )

# sql to delete a row by the primary key of table1
sqlDelete = """
delete from
table1
where
pkcol1 = :1 and
pkcol2 = :2
"""

# connect to the database
try:
dbCon = informixdb.connect("%s@%s" % (database, server), autocommit = False)
except informixdb.DatabaseError, e:
print "unable to connect to %s@%s, %ld"  % (database, server, e.sqlcode)
sys.exit(2)

# define select and delete cursors
try:
dbSelectCursor = dbCon.cursor(rowformat = informixdb.ROW_AS_OBJECT, hold=True)
dbDeleteCursor = dbCon.cursor()
except informixdb.DatabaseError, e:
print "unable to define cursors, %ld"  % (e.sqlcode, )
sys.exit(2)

# set some session attributes
try:
dbSelectCursor.execute("set lock mode to wait")
dbSelectCursor.execute("set isolation dirty read")
except informixdb.DatabaseError, e:
print "unable to set session attributes, %ld"  % (e.sqlcode, )
sys.exit(2)

try:
# select the primary key of all rows in table1 that meet our where clause
dbSelectCursor.execute(sqlSelect)

numRowsInTransaction = 0
totalRows = 0
startTime = time.time()

# for each row that meets our where clause, delete it
# committing the transaction and checking engine load at the user
# defined intervals
for dbRow in dbSelectCursor:
if verbose:
print "deleting row pkcol1 = %ld and pkcol2 = %ld" % (dbRow.pkcol1, dbRow.pkcol2)

# attempt to delete this row
try:
dbDeleteCursor.execute(sqlDelete, (dbRow.pkcol1, dbRow.pkcol2))
numRowsInTransaction = numRowsInTransaction + 1
totalRows = totalRows + 1
except informixdb.DatabaseError, e:
print "unable to delete row pkcol1 = %ld and pkcol2 = %ld, %ld" % (dbRow.pkcol1, dbRow.pkcol2, e.sqlcode)

# if we have met out rows to delete per transaction limit,
# commit the transaction, sleep and check engine load
if numRowsInTransaction == numDelPerTransaction:
dbCon.commit()

print "deleted %d rows [%f rows/second], sleeping %d seconds" % (totalRows, totalRows / (time.time() - startTime), sleepSeconds)
sys.stdout.flush()

numRowsInTransaction = 0

time.sleep(sleepSeconds)
wt4logbf(2, 30)

# commit the last transaction
dbCon.commit()

print "deleted %d rows" % totalRows

except informixdb.DatabaseError, e:
print "unable to execute %s,  %ld" % (sqlSelect, e.sqlcode)
sys.exit(2)

if __name__ == "__main__":
main()
Пример #13
0
def connect():
    return informixdb.connect('protrack@ptrack_odbc', user=PROTRACK_USER, password=PROTRACK_PASSWORD)
Пример #14
0
                   borderWidth=0,
                   borderColor='#000000',
                   textColor=black))

styleN = styles['Justify']
styleN1 = styles['Justify1']
styleN2 = styles['Justify2']
styleN3 = styles['Justify3']
styleN4 = styles['Justify4']
styleN5 = styles['Justify5']
'''
Parámetros de conexión
'''
os.environ['INFORMIXSERVER'] = 'ol_urbano'
conn = informixdb.connect('scm30@ol_urbano',
                          user='******',
                          password='******')
conn.autocommit = True
try:
    cursor = conn.cursor(rowformat=informixdb.ROW_AS_DICT)
    try:
        #print "call scm_reclamo_impresion(" + str(params[1])+","+ str(params[0])+","+str(params[6])+","+str(params[2])+","+str(params[3])+","+str(params[7])+","+str(params[4]) + ")"
        cursor.callproc(
            "scm_reclamo_impresion",
            (str(params[1]), str(params[0]), str(params[6]), str(
                params[2]), str(params[3]), str(params[7]), str(params[4])))
        rs = cursor.fetchall()
    finally:
        cursor.close()
finally:
    conn.close()
Пример #15
0
#!/bin/python
import informixdb
import os

Database = 'd_1460371357365469'
#Server='172.16.13.186'
Server='ifxserver1'
Username = '******'
Password = '******'

cur = conn = None
conn = informixdb.connect(Database+'@'+Server,Username,Password)
if not conn:
	raise Exception("Failed to connect via SQL to " + dbservername)
else:
	print("connected to database!\nuse "+__name__+".conn.cursor()")
Пример #16
0
#!/usr/bin/python

import Adafruit_BBIO.ADC as ADC
import datetime
import time
import informixdb
import sys

# the name of our temperature sensor
sensor_pin='P9_40'

ADC.setup()

# connect to the informix database
conn = informixdb.connect('iotdata')
curr = conn.cursor()

while True:
	
	# read in temperature data from the sensor
	reading = ADC.read(sensor_pin)
	
	# convert temperature reading to standardized units
	millivolts = reading * 1800
	temp_c = (millivolts - 500) / 10
	temp_f = (temp_c * 9/5) + 32
	
	# create a timestamp string
	dt = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S.%f")
	pdt = dt[:-1]
	
Пример #17
0
 def get_new_connection(self, conn_params):
     self.connection = Database.connect(**conn_params)
     return self.connection
Пример #18
0
 def connect(self):
     self.conn = informixdb.connect(self.database,
                                    user=self.user,
                                    password=self.password)
     return self.conn
Пример #19
0
def dbconn(creds):
    (dbname, dbuser, dbpass) = creds
    conn = informixdb.connect(dbname, user=dbuser, password=dbpass)
    conn.autocommit = True
    return conn