Posts

Showing posts with the label SQL

SqlAlchemy[SQLite] database connection in Python-Flask

Flask is a Python framework which can be used to build the web application from scratch. Flask is a micro-framework which capable to build websites like Instagram, twitter and anything at programmers will. SqlAlchemy is a package in Python Flask which simplifies database connections. The following simple Application will explain ..... how. This project was built on windows OS and Pycharm IDE The connection string from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['DATABASE_FILE'] = 'app2.db' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + app.config['DATABASE_FILE'] app.config['SECRET_KEY'] = '123456790' db = SQLAlchemy(app) So the db is like the cursor to the database. Read More The complete SQLite Project can be downloaded from GitHub

Make database read/write in MS SQL Server

When we have the problem with READ ONLY SQL DATABASE(It can happen while we trying to attach different version database file). First up all we need to make the security of ldf and mdf file to everyone/current user, preferably Full Control. And then simply execute the script ( if this script not working,  do the same for folder and drive in which the database file resides. ) USE [master] Go Alter database [readonlydb] set READ_WRITE WITH NO_WAIT GO Or use the query without the NO_WAIT option. USE [master] Go Alter database [readonlydb] set READ_WRITE GO

Converting Text number into number in Order By in SQL

Select * from emp order by code [ here 'code' is a text field], result in unordered result due to the data type, in MS SQL and My SQL too. To override this issue we can simply cast the field code using the cast  operator. select * from emp order by cast (code as int) Asc