mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-03-03 17:37:06 +01:00
psycopg2 only imported when postgres.
This commit is contained in:
parent
e2d43e786f
commit
46eab3b35e
1 changed files with 5 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
import trio
|
||||
import psycopg2
|
||||
from typing import Optional
|
||||
from contextlib import asynccontextmanager
|
||||
from sqlalchemy import create_engine # type: ignore
|
||||
from sqlalchemy_aio import TRIO_STRATEGY # type: ignore
|
||||
|
@ -13,8 +13,8 @@ SQLITE = "SQLITE"
|
|||
|
||||
|
||||
class Compat:
|
||||
type = "<inherited>"
|
||||
schema = "<inherited>"
|
||||
type: Optional[str] = "<inherited>"
|
||||
schema: Optional[str] = "<inherited>"
|
||||
|
||||
def interval_seconds(self, seconds: int) -> str:
|
||||
if self.type == POSTGRES:
|
||||
|
@ -84,6 +84,8 @@ class Database(Compat):
|
|||
database_uri = LNBITS_DATABASE_URL
|
||||
self.type = POSTGRES
|
||||
|
||||
import psycopg2 # type: ignore
|
||||
|
||||
DEC2FLOAT = psycopg2.extensions.new_type(
|
||||
psycopg2.extensions.DECIMAL.values,
|
||||
"DEC2FLOAT",
|
||||
|
|
Loading…
Add table
Reference in a new issue