Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import psycopg2
- conn=psycopg2.connect("dbname=guest user=guest password=guest")
- cur=conn.cursor()
- def query1():
- cur.execute("select id from taxi_services;")
- results=cur.fetchall()
- i=0
- tmp=""
- for row in results:
- tmp=int(row[0])
- cur.execute("insert into dw_taxis (taxi_id,n_taxi) values(%s,%s);",(i,tmp))
- conn.commit()
- i=i+1
- query2(tmp)
- def query2(id):
- i=0
- cur.execute("select to_timestamp(initial_ts) from taxi_services where id=%s;",(id,))
- results=cur.fetchall()
- for row in results:
- tmp=""
- tmp=str(row[0])
- x=tmp.split('-')
- dia=x[2].split(" ")[0]
- ano=x[0]
- mes=int(x[1])
- tri=mes%3
- print(ano,mes,dia,tri)
- #query1()
- query2(7268)
- cur.close()
Add Comment
Please, Sign In to add comment