-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from lioramilbaum/create_publish
Create publish [RHELDST-2159]
- Loading branch information
Showing
17 changed files
with
326 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from sqlalchemy.orm import Session | ||
|
||
from .models import Publish | ||
|
||
|
||
def create_publish(db: Session): | ||
db_publish = Publish() | ||
db.add(db_publish) | ||
db.commit() | ||
db.refresh(db_publish) | ||
return db_publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
from sqlalchemy import create_engine | ||
from sqlalchemy.ext.declarative import declarative_base | ||
from sqlalchemy.orm import sessionmaker | ||
|
||
from .settings import get_settings | ||
|
||
# The database name is identical to the user name | ||
SQLALCHEMY_DATABASE_URL = ( | ||
"postgresql://{s.db_service_user}:{s.db_service_pass}@" | ||
"{s.db_service_host}:{s.db_service_port}/{s.db_service_user}" | ||
).format(s=get_settings()) | ||
engine = create_engine(SQLALCHEMY_DATABASE_URL) | ||
|
||
def get_db(): | ||
"""Get db engine | ||
The database name is identical to the user name | ||
See additional info: | ||
https://devopstuto-docker.readthedocs.io/en/latest/docker_library/postgresql/postgresql.html#postgres-user # noqa | ||
""" | ||
SQLALCHEMY_DATABASE_URL = ( | ||
"postgresql://{s.db_service_user}:{s.db_service_pass}@" | ||
"{s.db_service_host}:{s.db_service_port}/{s.db_service_user}" | ||
).format(s=get_settings()) | ||
return create_engine(SQLALCHEMY_DATABASE_URL) | ||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | ||
|
||
Base = declarative_base() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import uuid | ||
|
||
from sqlalchemy import Column | ||
from sqlalchemy.dialects.postgresql import UUID | ||
|
||
from .database import Base | ||
|
||
|
||
class Publish(Base): | ||
|
||
__tablename__ = "publishes" | ||
|
||
id = Column( | ||
UUID(as_uuid=True), | ||
primary_key=True, | ||
default=uuid.uuid4, | ||
unique=True, | ||
nullable=False, | ||
) | ||
|
||
def __init__(self): | ||
pass |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from uuid import UUID | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class Publish(BaseModel): | ||
id: UUID | ||
|
||
class Config: | ||
orm_mode = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ gunicorn | |
dataclasses;python_version<'3.7' | ||
psycopg2 | ||
sqlalchemy | ||
async-exit-stack | ||
async-generator |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.