cedricbonhomme / newspipe

A web news aggregator.
https://www.newspipe.org
GNU Affero General Public License v3.0
419 stars 39 forks source link

`flask db_create` fails on sqlite #62

Closed sfermigier closed 6 months ago

sfermigier commented 6 months ago

With the default sqlite.py config:

  File "/ghq/github.com/cedricbonhomme/newspipe/newspipe/commands.py", line 35, in db_create
    application.config["DB_CONFIG_DICT"],
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'DB_CONFIG_DICT'

The code in db_create() is specific to postgres, and won't work with other databases.

def db_create(db, db_config_dict, database_name):
    db_conn_format = "postgresql://{user}:{password}@{host}:{port}/{database}"
    db_conn_uri_default = db_conn_format.format(database="postgres", **db_config_dict)
    engine_default = create_engine(db_conn_uri_default)
    conn = engine_default.connect()
    conn.execute(text("COMMIT"))
    conn.execute(text("CREATE DATABASE %s" % database_name))
    conn.close()
sfermigier commented 6 months ago

A first step would be to fix the README.

cedricbonhomme commented 6 months ago

Indeed, I do not use this for my local instance which is using SQLite. Thank you !