Exemple #1
0
def get_volume(dsn, year):
	conn=ODBC.connect(dsn=dsn, user="", password="")
	cursor=conn.cursor()
	query='select kind, V1 as mol1, V2 as mol2, Vsr as srd, Vpr as prs, VIspper as spl_per, Vper as per from "S%s$"' % year
	#print query
	cursor.execute(query)
	#print cursor.description
	#print cursor.fetchall()
	rc=ModelParameter()
	data=cursor.fetchone()
	s=0
	while data:
		(kind, mol1, mol2, srd, prs, spl_per, per)=data
		spl=spl_per - per
		kind=int(kind)
		setattr(rc, "mol1_%i" % kind, mol1)
		setattr(rc, "mol2_%i" % kind, mol2)
		setattr(rc, "srd_%i" % kind, srd)
		setattr(rc, "prs_%i" % kind, prs)
		setattr(rc, "spl_%i" % kind, spl)
		setattr(rc, "per_%i" % kind, per)
		s+=mol1+ mol2+ srd+ prs+ spl_per
		data=cursor.fetchone()
	print "Summ vol:", s
	return ModelParameter({"V":rc})
Exemple #2
0
	def __init__(self, dsn, regions, last_year=2050, tree_names=[], **keyargs):
		global ForestKind
		self.dsn=dsn
		self.last_year=last_year
		tree_names=FOREST_KIND
		self.regions=regions
		self.conn=ODBC.connect(dsn=dsn, user="", password="")

		ForestModel.__init__(self, tree_names, **keyargs)

		self.options["culture_kind"]=101 # i.e. Sosna
Exemple #3
0
	def __init__(self, dsn, **keyargs):
		conn=ODBC.connect(dsn=dsn, user="", password="")
		c=conn.cursor()
		c.execute("select P34, LESX from bd_les_o")
		all=c.fetchall()
		n=[]
		for (year, name) in all:
			try:
				if int(year)>0:
					n.append(int(name))
			except ValueError:
				pass
		#print n
		#n=[11252218,11252207]
		#n=[11252218]
		GISForestModel.__init__(self, dsn, n, **keyargs)
Exemple #4
0
	def __init__(self, dsn, year=1973, tree_names=[], **keyargs):
		global ForestKind
		self.dsn=dsn
		self.year=year
		if DEBUG<10:
			self.conn=ODBC.connect(dsn, user="", password="", clear_auto_commit=0)
			cursor=self.conn.cursor()
			cursor.execute('select Kind from "S%s$"' % year)
			fks=cursor.fetchall()
			if fks is None:
				raise ValueError, "wrong year is given (returned empty set)"
			tree_names=map(lambda (x,): int(x), fks)
		else:
			tree_names=[101,102,103,104,105,124,125]
		#tree_names=[101]
		if DEBUG:
			print "tree_names:", tree_names
		#raw_input("Connect debugger")
		ForestModel.__init__(self, tree_names, **keyargs)

		self.options["culture_kind"]=101 # i.e. Sosna
import mx.ODBC.Windows as odbc
import dbcp # contains pp function
conn = odbc.connect("MyDSN")
curs = conn.cursor()
curs.execute("""SELECT Name, LinkText, Pageset FROM StdPage
                ORDER BY PageSet, Name""")
rows = curs.fetchall()
print "\n\nWithout rowlens:"
print dbcp.pp(curs, rows)
print "\n\nWith rowlens:"
print dbcp.pp(curs, rows, rowlens=1)
conn.close()
Exemple #6
0
import dtuple
import mx.ODBC.Windows as odbc
flist = ["Name", "Num", "LinkText"]
descr = dtuple.TupleDescriptor([[n] for n in flist])
conn = odbc.connect("HoldenWebSQL")  # Connect to a database
curs = conn.cursor()  # Create a cursor
sql = """SELECT %s FROM StdPage
            WHERE PageSet='Std' AND Num<25
            ORDER BY PageSet, Num""" % ", ".join(flist)
print sql
curs.execute(sql)
rows = curs.fetchall()
for row in rows:
    row = dtuple.DatabaseTuple(descr, row)
    print "Attribute: Name: %s Number: %d" % (row.Name, row.Num or 0)
    print "Subscript: Name: %s Number: %d" % (row[0], row[1] or 0)
    print "Mapping:   Name: %s Number: %d" % (row["Name"], row["Num"] or 0)
conn.close()
Exemple #7
0
import dtuple
import mx.ODBC.Windows as odbc

flist = ["Name", "Num", "LinkText"]

descr = dtuple.TupleDescriptor([[n] for n in flist])

conn = odbc.connect("HoldenWebSQL") # Connect to a database
curs = conn.cursor()                # Create a cursor

sql = """SELECT %s FROM StdPage
            WHERE PageSet='Std' AND Num<25
            ORDER BY PageSet, Num""" % ", ".join(flist)
print sql
curs.execute(sql)
rows = curs.fetchall()

for row in rows:
    row = dtuple.DatabaseTuple(descr, row)
    print "Attribute: Name: %s Number: %d" % (row.Name, row.Num or 0)
    print "Subscript: Name: %s Number: %d" % (row[0], row[1] or 0)
    print "Mapping:   Name: %s Number: %d" % (row["Name"], row["Num"] or 0)

conn.close()
Exemple #8
0
import mx.ODBC.Windows as odbc
import dbcp  # contains pp function
conn = odbc.connect("MyDSN")
curs = conn.cursor()
curs.execute("""SELECT Name, LinkText, Pageset FROM StdPage
                ORDER BY PageSet, Name""")
rows = curs.fetchall()
print "\n\nWithout rowlens:"
print dbcp.pp(curs, rows)
print "\n\nWith rowlens:"
print dbcp.pp(curs, rows, rowlens=1)
conn.close()
Exemple #9
0
	def __init__(self,dsn,isTemporary=False):
		#self.dbapi = sqlite
		self._dbconn = odbc.connect(dsn)
		self._isTemporary = isTemporary
		self._dsn = dsn
Exemple #10
0
 def __init__(self, dsn, isTemporary=False):
     #self.dbapi = sqlite
     self._dbconn = odbc.connect(dsn)
     self._isTemporary = isTemporary
     self._dsn = dsn