Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

database with python

#create database in python with mysql

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword"
)

mycursor = mydb.cursor()

mycursor.execute("CREATE DATABASE mydatabase")
Comment

create a database in python

# Here is a sample from https://www.w3schools.com/python/python_mysql_create_db.asp 

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword"
)

mycursor = mydb.cursor()

mycursor.execute("CREATE DATABASE mydatabase")
Comment

database with python

#connect to sqlite database in python

import sqlite3

connection = sqlite3.connect("survey.db")
cursor = connection.cursor()
cursor.execute("SELECT Site.lat, Site.long FROM Site;")
results = cursor.fetchall()
for r in results:
    print(r)
cursor.close()
connection.close()
Comment

python database programming

use a python library called pyodbc

pip install pyodbc, you will also need to download the relavant SQL driver for the type and version of what SQL you are using.
Comment

PREVIOUS NEXT
Code Example
Python :: return function in python 
Python :: pyqt click through window 
Python :: xlabel not showing matplotlib 
Python :: python redis delete many 
Python :: python how to make a png 
Python :: for loop only for first 10 python 
Python :: django make app 
Python :: pandas read columns as list 
Python :: python count how many times a word appears in a string 
Python :: putting in text in python 
Python :: xlrd documentation 
Python :: how to write a function in python 
Python :: pandas find fifth caracter in field and change cell based on that number 
Python :: python autoclick website 
Python :: str count python 
Python :: python import list from py file 
Python :: difference between this and super 
Python :: python debugging 
Python :: topological sort 
Python :: How to add all the numbers of a list using python? 
Python :: py array contains 
Python :: python == vs is 
Python :: change value in tuple 
Python :: Returns the first row as a Row 
Python :: Counter() Function 
Python :: Python NumPy expand_dims Function Example 
Python :: python dict delete key 
Python :: Python List count() example with numbers 
Python :: time conversion 
Python :: python built in libraries 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =