File tree Expand file tree Collapse file tree 5 files changed +48
-12
lines changed
Expand file tree Collapse file tree 5 files changed +48
-12
lines changed Original file line number Diff line number Diff line change 1+ # For both URLs, the correct driver is added by the container
2+
13# Matomo connection
2- MARIADB_URL = <url >
4+ MARIADB_URL = <"mysql://user:password@localhost:3306/database" >
35
46# Macrostrat connection
5- DATABASE_URL = <url >
7+ DATABASE_URL = <"postgresql://user:pass@localhost:5432/dbname" >
Original file line number Diff line number Diff line change 77
88load_dotenv ()
99
10- DATABASE_URL = os .getenv ("DATABASE_URL" )
10+ raw_url = os .getenv ("DATABASE_URL" )
11+
12+ # Ensure it uses asyncpg
13+ if raw_url .startswith ("postgresql://" ):
14+ raw_url = raw_url .replace ("postgresql://" , "postgresql+asyncpg://" , 1 )
15+ elif not raw_url .startswith ("postgresql+asyncpg://" ):
16+ raise ValueError (
17+ "Invalid DATABASE_URL: must start with postgresql:// or postgresql+asyncpg://"
18+ )
19+
20+ DATABASE_URL = raw_url
1121
1222engine = create_async_engine (DATABASE_URL , echo = True )
1323
Original file line number Diff line number Diff line change 77
88load_dotenv ()
99
10- DATABASE_URL = os .getenv ("DATABASE_URL" )
10+ raw_url = os .getenv ("DATABASE_URL" )
11+
12+ # Ensure it uses asyncpg
13+ if raw_url .startswith ("postgresql://" ):
14+ raw_url = raw_url .replace ("postgresql://" , "postgresql+asyncpg://" , 1 )
15+ elif not raw_url .startswith ("postgresql+asyncpg://" ):
16+ raise ValueError (
17+ "Invalid DATABASE_URL: must start with postgresql:// or postgresql+asyncpg://"
18+ )
19+
20+ DATABASE_URL = raw_url
1121
1222engine = create_async_engine (DATABASE_URL , echo = True )
1323
Original file line number Diff line number Diff line change 99
1010BATCH_SIZE = 1000 # Adjust as needed
1111
12- # Database URL format: mysql+asyncmy://user:password@host:port/database
13- DATABASE_URL = os .getenv (
14- "MARIADB_URL" , "mysql+asyncmy://user:password@localhost:3306/database"
15- )
12+ raw_url = os .getenv ("MARIADB_URL" )
13+
14+ # Ensure the URL uses asyncmy driver
15+ if raw_url .startswith ("mysql://" ):
16+ raw_url = raw_url .replace ("mysql://" , "mysql+asyncmy://" , 1 )
17+ elif not raw_url .startswith ("mysql+asyncmy://" ):
18+ raise ValueError (
19+ "Invalid DATABASE_URL: must start with mysql:// or mysql+asyncmy://"
20+ )
21+
22+ DATABASE_URL = raw_url
1623
1724# Create async engine
1825engine = create_async_engine (DATABASE_URL , echo = True )
Original file line number Diff line number Diff line change 1010
1111BATCH_SIZE = 1000 # Adjust batch size as needed
1212
13- # Database URL format: mysql+asyncmy://user:password@host:port/database
14- DATABASE_URL = os .getenv (
15- "MARIADB_URL" , "mysql+asyncmy://user:password@localhost:3306/database"
16- )
13+ raw_url = os .getenv ("MARIADB_URL" )
14+
15+ # Ensure the URL uses asyncmy driver
16+ if raw_url .startswith ("mysql://" ):
17+ raw_url = raw_url .replace ("mysql://" , "mysql+asyncmy://" , 1 )
18+ elif not raw_url .startswith ("mysql+asyncmy://" ):
19+ raise ValueError (
20+ "Invalid DATABASE_URL: must start with mysql:// or mysql+asyncmy://"
21+ )
22+
23+ DATABASE_URL = raw_url
1724
1825# Create async SQLAlchemy engine
1926engine = create_async_engine (DATABASE_URL , echo = True )
You can’t perform that action at this time.
0 commit comments