Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- articulos = db.Table('inmart', meta, autoload=True, autoload_with=engine)
- query = db.select(
- [articulos]
- ).where(
- db.and_(
- articulos.c.ciacodigo == '01',
- articulos.c.marcodigo == 'VG'
- )
- )
- rp = engine.execute(query)
- resultado = rp.fetchall()
- with open('temp.csv', 'w') as file:
- for row in resultado:
- s = ''
- for element in row:
- if element == '' or element == None:
- s += ','
- else:
- try:
- if '.' in str(element):
- value = float(element)
- else:
- value = int(element)
- s += '{},'.format(element)
- except ValueError:
- s += '\"{}\",'.format(str(element))
- file.write('{}\n'.format(s[:-1]))
- """
- elif type(element) == int or type(element) == float:
- value = str(element).rstrip('0').rstrip('.')
- element = float(value) if '.' in value else int(value)
- s += '{},'.format(element)
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement