Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

insert data in table python

import sqlite3
connection= sqlite3.connect('sqlite.db')
cursor = connection.cursor()
cursor.execute('''CREATE TABLE if not Exists Website
               (Post text, Autor text, Views real)''')

post_text = 'this is a raw  post'
post_author = 'alixapordev'
post_views = 6900

INSERT_QUERY = f"INSERT INTO Website VALUES ('{post_text}','{post_author}','{post_views}')"
cursor.execute(INSERT_QUERY)
# Save (commit) the changes
connection.commit()
# close connection
connection.close() 
   
Comment

python data insert

import sqlite3 
# python data insert 
conn = sqlite3.connect('TestDB.db') 
name=input("enter your name 
 ")
conutryID=int(input("enter your country id 
 "))
sql = f''' INSERT INTO CLIENTS(Client_Name,Country_ID,Date)
              VALUES('{name}',"{conutryID}","30/3/2022") '''
conn.execute(sql)
conn.commit()
conn.close()
Comment

PREVIOUS NEXT
Code Example
Python :: beautiful soup 4 
Python :: reverse range in python 
Python :: Adding function to a varieble in python 
Python :: pandas series index of value 
Python :: Randint Random Library 
Python :: pyspark group by and average in dataframes 
Python :: python elasticsearch put index 
Python :: get number of zero is a row pandas 
Python :: Select rows without NaN in specific column 
Python :: how to split a string by character in python 
Python :: python timedelta to seconds 
Python :: python expressions 
Python :: what is wsgi 
Python :: install python altair 
Python :: leap year python 
Python :: pandas look for values in column with condition 
Python :: how to aggregate multiple columns in pyspark 
Python :: pygame rotate image 
Python :: python if in range 
Python :: python int to binary string 
Python :: number system conversion python 
Python :: round decimal to 2 places python 
Python :: how to get the first key of a dictionary in python 
Python :: split a string with 2 char each in python 
Python :: making a virtual environment python 
Python :: install play sound python terminal 
Python :: pandas calculate same day 3 months ago dateoffset 
Python :: import file in parent directory python 
Python :: textclip python arabic 
Python :: check type of django messages 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =