Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

use sqlalchemy to create sqlite3 database

from sqlalchemy import create_engine
import pandas as pd
# creates an engine for a database in current directory 
engine = create_engine('sqlite:///yourDatabaseName.sqlite3') 
# creates a dataframe in memory
df = pd.DataFrame({'tablename' : ['Data 1', 'Data 2', 'Data 3']})
# stores the dataframe as a table in the database
df.to_sql('tablename', con=engine)
# queries the table and stores the results in another dataframe
dfOne = pd.read_sql_table('tablename', engine)
# or you can create a custom sql query and store the results in a dataframe
dfTwo = pd.DataFrame(engine.execute("SELECT * FROM tablename").fetchall())
Comment

PREVIOUS NEXT
Code Example
Python :: message box for python 
Python :: python show image cv2 
Python :: rvec tvec ros message 
Python :: print(DATA.popitem()) 
Python :: dopleganger 
Python :: Not getting spanish characters python 
Python :: def __init__ python not overwrite parrent class 
Python :: how to close python with a line of code 
Python :: what is the meaning of illiteral with base 10 
Python :: folium python map in full screen 
Python :: python how to code discord bot kick members 
Python :: cv2 gaussian blur 
Python :: Python create a digital clock 
Python :: Pandas bins pd.cut() 
Python :: replace "-" for nan in dataframe 
Python :: datafram from one date to another 
Python :: fourreau de maroquin 
Python :: creating a new enviroment in conda 
Python :: pil to grayscale 
Python :: python test if number in string 
Python :: scikit normalize 
Python :: JUPYTER CONSUMES 100 disk 
Python :: views.home not found django 
Python :: python get ip info 
Python :: python selenium geolocation 
Python :: python how to obfuscate code 
Python :: sheebang python 
Python :: how to install django in virtual environment in ubuntu 
Python :: compute mfcc python 
Python :: pandas column to numpy array 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =