Posts

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

Distinct count in MS SQL

The below code will retrieve distinct count from a table in SQL select ename, count(ename) from emp Group by ename having (count(ename)>1)

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

OLEDB Database connection string in C#.Net

OledDb database connections allow C# developers to build data powered applications with Access database. It can be possible with Database connection object and command object. Connection string  For connecting .mdb Access files you can use the following connection string, string connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/.Net Project/PharmaERP/PharmaERP/PharmaData.mdb"; and for the Access 2007, 2012,2016 databases you have to use the following one. string connstr = "Provider=Microsoft.ACE.OLEDB.12.0;;Data Source=D:/.Net Project/PharmaERP/pharmaData.accdb;Jet OLEDB:Database Password=password";  Now we are ready to setup the connection, let build the connection objects and get started. Connecting database with OleDbConnection object.     OleDbConnection conn; OleDbCommand Rs; public void Connect() { conn = new OleDbConnection(connstr); conn.Open(); } With the OleDbConnection o

How to Flask with Python : Making of a Flask website

Flask is the one of the most popular Micro Framework which enables programmers to quickly build web applications. Linkedin, Pinterest are some of the finest examples of this framework. The Framework was initially coded by Armin Ronacher of Pocoo. Let's start with Installation Install Flask First up all you need to install Python on your system if you don't have to get one from www.python.org. You can install Flask from Python Package Index which requires the PIP command and an internet connection. Learn how to get PIP? Install flask using the following command line, the simplest way to install Flask on your system. On Windows go to your command prompt/shell and issue the pip command. D:/> pip install flask It will take some time to finish the procedures. Uninstalling Flask D:/> pip install flask will remove Flask packages from your system Create your first App Flask is Fun Create a file called hello.py from flask import Flask app =

Install packages with the Python Package Index [PIP]

PyPI - the Python Package Index is the largest Python package repository meant for the Python programming community. It consists of dozens of packages from programmers around the world which minimize the coding tasks. Flask and Django were some of the top Python frameworks in the PyPI. The easiest way to install a Python Package from the repository is pip command, a small Python program. You can install the pip by download and compile the get-pip.py files. Compiling get-pip Go to your command prompt and locate the get-pip.py file and compile with Python interpreter C:/>Python get-pip.py  and will install the Python Package Index command on your computer. Installing packages Let's install Django framework. C:/> pip install Django will install the Django web framework on your system, make sure your internet/Wi-Fi connection turned on. Uninstalling packages You can also use the Python Package Index (pip) to uninstall a package as follows C:/> pip uni

Copying rows from one Access database to Another using Query

In access database, we can copy rows from one table to another using query. How can we transfer rows from one database to another? Using the in   keyword in Insert statement we can specify an external database path as follows in access query insert into Account_Transactions(Date ,Name ,Type ) in 'D:\Sherpharma\T.mdb' select  Account_Transactions.Date,Account_Transactions.Name,Account_Transactions.Type from  Account_Transactions Here we copy the rows from current database to the T.mdb files. We can also use this query in programming as well.