Advertisement
Guest User

Fucked up

a guest
Feb 6th, 2014
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import sqlite3
  2. from datetime import date
  3. conn = sqlite3.connect(':memory:')
  4. cur = conn.cursor()
  5.  
  6. #creating table
  7. cur.execute('create table first (number integer, firstdate real, seconddate2 real, summ float, paid float, diff float)')
  8.  
  9. def dtj(my_date):
  10.     """Returns the Julian day number of a date."""
  11.     a = (14 - my_date.month)//12
  12.     y = my_date.year + 4800 - a
  13.     m = my_date.month + 12*a - 3
  14.     return my_date.day + ((153*m + 2)//5) + 365*y + y//4 - y//100 + y//400 - 32045
  15.  
  16. dates = [dtj(date(2013, 12, 31)), dtj(date(2014, 1, 4))]
  17.  
  18.  
  19. #filling it with input data
  20. cur.executemany('insert into first values (123456, ?, ?, 99999.99, 99999.99, 0)', dates)
  21.  
  22. for row in cur.execute('select * from first order by number'):
  23.     print row
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement