title: Connect sql server to Python3 - client-server
body: <p>i'm new in socket programming with python i wrote some code for client and server that is not completed.
  i want to connect my server side to Sql server dbms to store data there (this is a student management system) i want to send some data from client side then server side store them on data base and when got asked by client return them.
  Here is my both side codes:
  this is client:</p>
  
  <pre><code>    import socket
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  host ="127.0.0.1"
  port =8000
  
  
  def send(message):
     message=str(message)
     s.send(message.encode())
     data = s.recv(1024).decode()
     print (data)
  def end():
     s.close ()
  def menu1():
     print("Data has been saved to DB!\nWhat you need next?\n1.Close Connection.\n2.Enter More Data.\n3.Get Data.")
     while 1:
        m=input()
        if int(m)==1:
           end()
        elif int(m)==2:
           enter_data()
        elif int(m)==3:
           get_data()
        else:
           print("Choose a Num between 1-3!\n")
  
  def enter_data():
     flag=0
     while 1:
        if flag==0:
           r = input('enter amount of student: ')
        for i in range (0,int(r)):
           name=input("Enter Student %d name"%(i))
           send(name)
        break
     menu1()
  def start():
     s.connect((host,port))
     print("You are connected to server!")
     print("1.Enter Data")
     print("2.Get Data")
     m=input()
     if int(m)==1:
        enter_data()
     elif int(m)==2:
        end()
  def menu():
     m = input("press any key to connect!\n");
     start()
  
  if __name__ == "__main__":
     menu()
  </code></pre>
  
  <p>and this is server side code:</p>
  
  <pre><code>import socket
  from threading import *
  
  serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  host = ""
  port = 8000
  #print (host)
  #print (port)
  serversocket.bind((host, port))
  
  class client(Thread):
      def __init__(self, socket, address):
          Thread.__init__(self)
          self.sock = socket
          self.addr = address
          self.start()
  
      def run(self):
          #amount=self.sock.recv(1024).decode()
          #amount=int(amount)
          #counter=0
          while 1:
              api=self.sock.recv(1024).decode()
              #print(self.sock.recv(1024).decode())
              print("Client sent some messages: %s"%(api))
              #api=self.sock.recv(1024).decode()
              if str(api)=="avarage":
                  avarage=2/10
                  c=str(avarage)
                  self.sock.send(c.encode())
              else:
                  avarage = 3 / 10
                  c = str(avarage)
                  self.sock.send(c.encode())
  
  serversocket.listen(5)
  print ("server started and listening to port:%s"%(port))
  while 1:
      clientsocket, address = serversocket.accept()
      client(clientsocket, address)
  </code></pre>
  
  <p>I'm a bit new in this type of programming so please give me a part of code that i need to add.
  thanks in advance.</p>