How to use sqlite on Heroku - sqlite

I will like to deploy an app that uses sqlite to Heroku. Googling for how to do this, I come across the official documentation of sqlite on hereku here
And the amazing thing is that, the documentation seems to be suggesting you should not use sqlite on heroku and then went further to tell you how to use Postgres instead!!!
Is it really impossible to use sqlite on heroku and have your data not transient?

Heroku has a database offering of its own, based on the Postgres database so it is necessary to switch so as to avoid the file-based SQlite. To connect to a Heroku database, you will need to use the Heroku CLI. That is the recommendation, as you have noted.
You can run heroku addons:add <your database choice, say the free tier one for example>. It is as simple as that.
If you try to run heroku config:get DATABASE_URL you will notice that a postgres://<> (now postgresql) has been created for you.

Related

Microsoft Azure App services: cannot write to sqlite database

I am trying to deploy my flask app on Microsoft Azure. On the deployed site it can read the db fine, but whenever I try to write to the db, it gives: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
My file structure inside the app folder is:
templates
app.py
db.sqlite
However when i run it on my local, everything works fine. Any ideas how I can solve this?
Run from Package makes wwwroot read-only, and you will receive an error when writing files to this directory. You may refer to below links might be helpful:
https://github.com/Azure/app-service-announcements/issues/84
https://learn.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package
There is not more information for us to help fixing your issue, such as the necessary code and configuration for using SQLAlchemy with SQLite.
So I suggest that you can carefully refer to the some topics about SQLite locked file for writing.
Database Locking Behavior / Concurrency
The items Client/Server Applications and High Concurrency of the section Situations Where A Client/Server RDBMS May Work Better in the SQLite offical page Appropriate Uses For SQLite.
Meanwhile, some existing SO threads may will help you.
sqlite3.OperationalError: database is locked
SQLAlchemy and SQLite: database is locked
Hope it helps. If you can update your description to post more helpful information, I will try to reproduce your issue and fix it, and then update my post.

Beginner questions on deployment and migrations

I'm working on a Symfony 2-application and I use Doctrine migrations to create the database. Now it is time to deploy my application to the production server, and I need some guidance on how to manage migrations. First, how can I get console access to my live server to run the migration command? If I can´t run migrations, can I import my local database to the new server, or will this break the application´s mapping structure, so it won´t work? I´m sorry if this seems like a silly question, but I really can´t find much information about this. I have searched for it a lot.
Several options:
A terminal connection to your deployment server to run the app/console there
Execute the migration in your local terminal, with env=prod, and with a parameters.yml file that points to your prod database
Export data from your local database, and import it in your remote one
Take care when doing these, and make proper backups to avoid data losses

How can I use sqlite in appfog?

I'm using flask on appfog.com to make a personal blog. Today I tried to use sqlite. I can run the application locally with sqlite but when I update the app to AppFog, it does not seem to work. I can't find how to use sqlite in AppFog's docs. Can anyone tell me?
Thanks...
Sorry for my poor english:-)
It's not recommended to use sqlite for your production apps on AppFog because the file storage is ephemeral. Every time you update your app the database will get blown away. You're better off creating and binding a postgres, mysql, or mongodb database service for your app. You can continue to use sqlite db locally but your production app will use the bound service.
See the Bind Service section of: https://docs.appfog.com/languages/python/flask

use sqlite with node.js - working module

I'm working on a node.js project and I would like to use some kind of database to store application data. I've searched for various DBMS and I've selected SQLite because I want my project to be able to run without installing heavy DBMS and because I want it to run both on linux and windows. however, all modules that we found, that connect node with SQLite are either very old, or cannot be installed due to bugs.
so, I want to ask if nowadays, 2012, there is a completely functional node.js module for SQLite.
I did a project last July (2012) in Node.JS v0.8.8, using the node-sqlite module (see https://github.com/developmentseed/node-sqlite3) and it worked just fine.
And, I successfully deployed and used this module on Heroku. However, the deployed portion of the project only involved reading out of the SQLite database – not writing. I suspect that writing into a SQLite deployed on Heroku would cause some issues, because it involves modifying the SQLite file in the file system, which AFAIK Heroku doesn't let you do.

Move a remote development database to local usage

I have been using a central MS SQL database located in the cloud to develop a web site project. I have recently found myself in situations, when I need to develop without the internet connection. I want to begin to use a locally available copy of the existing database, put it in App_Data folder.
What is the correct set of steps I need to undertake to get the project to work with local DB?
For example:
Detach a db from an existing SQL instance.
Copy to a development machine.
etc.
Moving a SQL-Server DB is not that hard. Look here for some methods to do it.
http://support.microsoft.com/kb/314546
I usually find the sp_detach + sp_attach method really easy.
I would create an empty shell database locally, then use one of the many schema comparison solutions available to make the local database look exactly like the cloud database.
Correct way is to create and regularly update your standalone copy of database using import/export. In particular MS SQL Server provides Import/Export Wizard tool for such purpose.
Make a backup
Copy backup file
Restore on your server
Restore/organise users

Resources