Tanishq Dubey
905e3c3977
All checks were successful
Docker Build and Publish / build (push) Successful in 6s
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
from sqlalchemy import create_engine, Column, Integer, String, DateTime, Float
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
Base = declarative_base()
|
|
|
|
class Photo(Base):
|
|
__tablename__ = 'photos'
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
input_filename = Column(String, nullable=False)
|
|
thumbnail_filename = Column(String, nullable=False)
|
|
focal_length = Column(String)
|
|
aperture = Column(String)
|
|
shutter_speed = Column(String)
|
|
date_taken = Column(DateTime)
|
|
iso = Column(Integer)
|
|
width = Column(Integer)
|
|
height = Column(Integer)
|
|
highlight_color = Column(String)
|
|
orientation = Column(Integer)
|
|
unique_key = Column(String(16), nullable=False) # Add this line
|
|
|
|
engine = create_engine('sqlite:///photos.db')
|
|
|
|
def init_db():
|
|
try:
|
|
Base.metadata.create_all(engine)
|
|
except Exception as e:
|
|
# Tables already exist, skip creation
|
|
pass
|
|
|
|
init_db()
|
|
Session = sessionmaker(bind=engine)
|