python - generate SEQUENCE on next day it will initialize using Psycopg -


Using PostgreSQL and Python We want to generate sequence based on daily basis as the next day begins with sequence 1.

We are using the Tryton framework.

Former: 201402170001 (Year 0001) Generates more than 100 sequences this day, next day it will start from 201402180001 .

We produce the sequence but we do not know how it should be disabled on every next date?

You can use datetime to get the date string .datetime.strftime < / Code> and use the string string formatting for the pad for some enhancements counter for four digits: datetime from datetime counter = 1 ("% 1% 2" P> To update the counter daily, you will need to store the current day, then reset it to 1 when it changes, like:

  if current_date! = DatetimeToday ( ): Counter = 1 # recieve Counter Wartman_deta = Detataim 

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -