mc-postgres-db 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: mc-postgres-db
3
+ Version: 0.1.0
4
+ Summary: Add your description here
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: alembic>=1.16.2
8
+ Requires-Dist: psycopg2>=2.9.10
9
+ Requires-Dist: ruff>=0.12.0
10
+ Requires-Dist: sqlalchemy>=2.0.41
File without changes
@@ -0,0 +1,83 @@
1
+ import os
2
+ from logging.config import fileConfig
3
+
4
+ from sqlalchemy import engine_from_config
5
+ from sqlalchemy import pool
6
+
7
+
8
+ from alembic import context
9
+ from tables import Base # Import your SQLAlchemy Base class
10
+ from dotenv import load_dotenv
11
+
12
+ load_dotenv() # Load environment variables from .env file
13
+
14
+ # this is the Alembic Config object, which provides
15
+ # access to the values within the .ini file in use.
16
+ config = context.config
17
+
18
+ # Interpret the config file for Python logging.
19
+ # This line sets up loggers basically.
20
+ if config.config_file_name is not None:
21
+ fileConfig(config.config_file_name)
22
+
23
+ # add your model's MetaData object here
24
+ # for 'autogenerate' support
25
+ # from myapp import mymodel
26
+ # target_metadata = mymodel.Base.metadata
27
+ target_metadata = Base.metadata # Use the metadata from your Base class
28
+
29
+ # other values from the config, defined by the needs of env.py,
30
+ # can be acquired:
31
+ # my_important_option = config.get_main_option("my_important_option")
32
+ url = os.environ["SQLALCHEMY_DATABASE_URL"]
33
+ config.set_main_option("sqlalchemy.url", url)
34
+
35
+
36
+ def run_migrations_offline() -> None:
37
+ """Run migrations in 'offline' mode.
38
+
39
+ This configures the context with just a URL
40
+ and not an Engine, though an Engine is acceptable
41
+ here as well. By skipping the Engine creation
42
+ we don't even need a DBAPI to be available.
43
+
44
+ Calls to context.execute() here emit the given string to the
45
+ script output.
46
+
47
+ """
48
+ url = config.get_main_option("sqlalchemy.url")
49
+ context.configure(
50
+ url=url,
51
+ target_metadata=target_metadata,
52
+ literal_binds=True,
53
+ dialect_opts={"paramstyle": "named"},
54
+ )
55
+
56
+ with context.begin_transaction():
57
+ context.run_migrations()
58
+
59
+
60
+ def run_migrations_online() -> None:
61
+ """Run migrations in 'online' mode.
62
+
63
+ In this scenario we need to create an Engine
64
+ and associate a connection with the context.
65
+
66
+ """
67
+ connectable = engine_from_config(
68
+ config.get_section(config.config_ini_section, {}),
69
+ prefix="sqlalchemy.",
70
+ poolclass=pool.NullPool,
71
+ )
72
+
73
+ with connectable.connect() as connection:
74
+ context.configure(connection=connection, target_metadata=target_metadata)
75
+
76
+ with context.begin_transaction():
77
+ context.run_migrations()
78
+
79
+
80
+ if context.is_offline_mode():
81
+ run_migrations_offline()
82
+ else:
83
+ run_migrations_online()
@@ -0,0 +1,149 @@
1
+ """empty message
2
+
3
+ Revision ID: 4056c087960a
4
+ Revises:
5
+ Create Date: 2025-06-23 18:38:27.569904
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ from alembic import op
12
+ import sqlalchemy as sa
13
+
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = "4056c087960a"
17
+ down_revision: Union[str, Sequence[str], None] = None
18
+ branch_labels: Union[str, Sequence[str], None] = None
19
+ depends_on: Union[str, Sequence[str], None] = None
20
+
21
+
22
+ def upgrade() -> None:
23
+ """Upgrade schema."""
24
+ # ### commands auto generated by Alembic - please adjust! ###
25
+ op.create_table(
26
+ "asset_type",
27
+ sa.Column("id", sa.Integer(), nullable=False),
28
+ sa.Column("name", sa.String(length=30), nullable=False),
29
+ sa.Column("description", sa.String(length=100), nullable=True),
30
+ sa.Column("is_active", sa.Boolean(), nullable=False),
31
+ sa.Column(
32
+ "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
33
+ ),
34
+ sa.Column(
35
+ "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
36
+ ),
37
+ sa.PrimaryKeyConstraint("id"),
38
+ )
39
+ op.create_table(
40
+ "provider_type",
41
+ sa.Column("id", sa.Integer(), nullable=False),
42
+ sa.Column("name", sa.String(length=30), nullable=False),
43
+ sa.Column("description", sa.String(length=1000), nullable=True),
44
+ sa.Column("is_active", sa.Boolean(), nullable=False),
45
+ sa.Column(
46
+ "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
47
+ ),
48
+ sa.Column(
49
+ "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
50
+ ),
51
+ sa.PrimaryKeyConstraint("id"),
52
+ )
53
+ op.create_table(
54
+ "asset",
55
+ sa.Column("id", sa.Integer(), nullable=False),
56
+ sa.Column("asset_type_id", sa.Integer(), nullable=False),
57
+ sa.Column("name", sa.String(length=30), nullable=False),
58
+ sa.Column("description", sa.String(), nullable=True),
59
+ sa.Column("is_active", sa.Boolean(), nullable=False),
60
+ sa.Column(
61
+ "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
62
+ ),
63
+ sa.Column(
64
+ "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
65
+ ),
66
+ sa.ForeignKeyConstraint(
67
+ ["asset_type_id"],
68
+ ["asset_type.id"],
69
+ ),
70
+ sa.PrimaryKeyConstraint("id"),
71
+ )
72
+ op.create_table(
73
+ "provider",
74
+ sa.Column("id", sa.Integer(), nullable=False),
75
+ sa.Column("provider_type_id", sa.Integer(), nullable=False),
76
+ sa.Column("name", sa.String(length=30), nullable=False),
77
+ sa.Column("description", sa.String(length=1000), nullable=True),
78
+ sa.Column("is_active", sa.Boolean(), nullable=False),
79
+ sa.Column(
80
+ "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
81
+ ),
82
+ sa.Column(
83
+ "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
84
+ ),
85
+ sa.ForeignKeyConstraint(
86
+ ["provider_type_id"],
87
+ ["provider_type.id"],
88
+ ),
89
+ sa.PrimaryKeyConstraint("id"),
90
+ )
91
+ op.create_table(
92
+ "provider_asset",
93
+ sa.Column("date", sa.Date(), nullable=False),
94
+ sa.Column("provider_id", sa.Integer(), nullable=False),
95
+ sa.Column("asset_id", sa.Integer(), nullable=False),
96
+ sa.Column("asset_code", sa.String(length=30), nullable=False),
97
+ sa.Column("is_active", sa.Boolean(), nullable=False),
98
+ sa.Column(
99
+ "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
100
+ ),
101
+ sa.Column(
102
+ "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
103
+ ),
104
+ sa.ForeignKeyConstraint(
105
+ ["asset_id"],
106
+ ["asset.id"],
107
+ ),
108
+ sa.ForeignKeyConstraint(
109
+ ["provider_id"],
110
+ ["provider.id"],
111
+ ),
112
+ sa.PrimaryKeyConstraint("date", "provider_id", "asset_id"),
113
+ )
114
+ op.create_table(
115
+ "provider_asset_order",
116
+ sa.Column("id", sa.Integer(), nullable=False),
117
+ sa.Column("timestamp", sa.DateTime(), nullable=False),
118
+ sa.Column("provider_id", sa.Integer(), nullable=False),
119
+ sa.Column("from_asset_id", sa.Integer(), nullable=False),
120
+ sa.Column("to_asset_id", sa.Integer(), nullable=False),
121
+ sa.Column("price", sa.Float(), nullable=True),
122
+ sa.Column("volume", sa.Float(), nullable=True),
123
+ sa.ForeignKeyConstraint(
124
+ ["from_asset_id"],
125
+ ["asset.id"],
126
+ ),
127
+ sa.ForeignKeyConstraint(
128
+ ["provider_id"],
129
+ ["provider.id"],
130
+ ),
131
+ sa.ForeignKeyConstraint(
132
+ ["to_asset_id"],
133
+ ["asset.id"],
134
+ ),
135
+ sa.PrimaryKeyConstraint("id"),
136
+ )
137
+ # ### end Alembic commands ###
138
+
139
+
140
+ def downgrade() -> None:
141
+ """Downgrade schema."""
142
+ # ### commands auto generated by Alembic - please adjust! ###
143
+ op.drop_table("provider_asset_order")
144
+ op.drop_table("provider_asset")
145
+ op.drop_table("provider")
146
+ op.drop_table("asset")
147
+ op.drop_table("provider_type")
148
+ op.drop_table("asset_type")
149
+ # ### end Alembic commands ###
@@ -0,0 +1,114 @@
1
+ """Adding new market table and content tables.
2
+
3
+ Revision ID: 8b53c8e91507
4
+ Revises: 4056c087960a
5
+ Create Date: 2025-06-23 18:45:51.916364
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ from alembic import op
12
+ import sqlalchemy as sa
13
+
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = "8b53c8e91507"
17
+ down_revision: Union[str, Sequence[str], None] = "4056c087960a"
18
+ branch_labels: Union[str, Sequence[str], None] = None
19
+ depends_on: Union[str, Sequence[str], None] = None
20
+
21
+
22
+ def upgrade() -> None:
23
+ """Upgrade schema."""
24
+ # ### commands auto generated by Alembic - please adjust! ###
25
+ op.create_table(
26
+ "content_type",
27
+ sa.Column("id", sa.Integer(), nullable=False),
28
+ sa.Column("name", sa.String(length=30), nullable=False),
29
+ sa.Column("description", sa.String(length=1000), nullable=True),
30
+ sa.Column("is_active", sa.Boolean(), nullable=False),
31
+ sa.Column(
32
+ "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
33
+ ),
34
+ sa.Column(
35
+ "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
36
+ ),
37
+ sa.PrimaryKeyConstraint("id"),
38
+ )
39
+ op.create_table(
40
+ "provider_asset_market",
41
+ sa.Column("timestamp", sa.DateTime(), nullable=False),
42
+ sa.Column("provider_id", sa.Integer(), nullable=False),
43
+ sa.Column("asset_id", sa.Integer(), nullable=False),
44
+ sa.Column("close", sa.Float(), nullable=True, comment="Closing price"),
45
+ sa.Column("open", sa.Float(), nullable=True, comment="Opening price"),
46
+ sa.Column("high", sa.Float(), nullable=True, comment="Highest price"),
47
+ sa.Column("low", sa.Float(), nullable=True, comment="Lowest price"),
48
+ sa.Column("volume", sa.Float(), nullable=True, comment="Volume traded"),
49
+ sa.Column("best_bid", sa.Float(), nullable=True, comment="Best bid price"),
50
+ sa.Column("best_ask", sa.Float(), nullable=True, comment="Best ask price"),
51
+ sa.ForeignKeyConstraint(
52
+ ["asset_id"],
53
+ ["asset.id"],
54
+ ),
55
+ sa.ForeignKeyConstraint(
56
+ ["provider_id"],
57
+ ["provider.id"],
58
+ ),
59
+ sa.PrimaryKeyConstraint("timestamp", "provider_id", "asset_id"),
60
+ )
61
+ op.create_table(
62
+ "provider_content",
63
+ sa.Column("id", sa.Integer(), nullable=False),
64
+ sa.Column("timestamp", sa.DateTime(), nullable=False),
65
+ sa.Column("provider_id", sa.Integer(), nullable=False),
66
+ sa.Column("provider_unique_identifier", sa.String(length=1000), nullable=False),
67
+ sa.Column("content_type_id", sa.Integer(), nullable=False),
68
+ sa.Column("author", sa.String(length=100), nullable=True),
69
+ sa.Column("title", sa.String(length=200), nullable=True),
70
+ sa.Column("content", sa.String(), nullable=False),
71
+ sa.Column(
72
+ "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
73
+ ),
74
+ sa.Column(
75
+ "updated_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
76
+ ),
77
+ sa.ForeignKeyConstraint(
78
+ ["content_type_id"],
79
+ ["content_type.id"],
80
+ ),
81
+ sa.ForeignKeyConstraint(
82
+ ["provider_id"],
83
+ ["provider.id"],
84
+ ),
85
+ sa.PrimaryKeyConstraint("id"),
86
+ )
87
+ op.create_table(
88
+ "asset_content",
89
+ sa.Column("content_id", sa.Integer(), nullable=False),
90
+ sa.Column("asset_id", sa.Integer(), nullable=False),
91
+ sa.Column(
92
+ "created_at", sa.DateTime(), server_default=sa.text("now()"), nullable=False
93
+ ),
94
+ sa.ForeignKeyConstraint(
95
+ ["asset_id"],
96
+ ["asset.id"],
97
+ ),
98
+ sa.ForeignKeyConstraint(
99
+ ["content_id"],
100
+ ["provider_content.id"],
101
+ ),
102
+ sa.PrimaryKeyConstraint("content_id", "asset_id"),
103
+ )
104
+ # ### end Alembic commands ###
105
+
106
+
107
+ def downgrade() -> None:
108
+ """Downgrade schema."""
109
+ # ### commands auto generated by Alembic - please adjust! ###
110
+ op.drop_table("asset_content")
111
+ op.drop_table("provider_content")
112
+ op.drop_table("provider_asset_market")
113
+ op.drop_table("content_type")
114
+ # ### end Alembic commands ###
@@ -0,0 +1,10 @@
1
+ Metadata-Version: 2.4
2
+ Name: mc-postgres-db
3
+ Version: 0.1.0
4
+ Summary: Add your description here
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: alembic>=1.16.2
8
+ Requires-Dist: psycopg2>=2.9.10
9
+ Requires-Dist: ruff>=0.12.0
10
+ Requires-Dist: sqlalchemy>=2.0.41
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ alembic/env.py
4
+ alembic/versions/4056c087960a_.py
5
+ alembic/versions/8b53c8e91507_adding_new_market_table_and_content_.py
6
+ mc_postgres_db.egg-info/PKG-INFO
7
+ mc_postgres_db.egg-info/SOURCES.txt
8
+ mc_postgres_db.egg-info/dependency_links.txt
9
+ mc_postgres_db.egg-info/requires.txt
10
+ mc_postgres_db.egg-info/top_level.txt
@@ -0,0 +1,4 @@
1
+ alembic>=1.16.2
2
+ psycopg2>=2.9.10
3
+ ruff>=0.12.0
4
+ sqlalchemy>=2.0.41
@@ -0,0 +1,17 @@
1
+ [project]
2
+ name = "mc-postgres-db"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "alembic>=1.16.2",
9
+ "psycopg2>=2.9.10",
10
+ "ruff>=0.12.0",
11
+ "sqlalchemy>=2.0.41",
12
+ ]
13
+
14
+ [dependency-groups]
15
+ dev = [
16
+ "python-dotenv>=1.1.0",
17
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+