Advertisement
Guest User

sayatloviesheraz

a guest
Nov 8th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import datetime
  2. #from django.db import models
  3. from django.utils import timezone
  4. from django.contrib.gis.db import models
  5. from django.contrib.gis import geos
  6.  
  7.  
  8.  
  9. import psycopg2
  10.  
  11.  
  12. class Question(models.Model):
  13. question_text = models.CharField(max_length=120)
  14. pub_date = models.DateTimeField(default=timezone.now)
  15.  
  16.  
  17. class Choice(models.Model):
  18. question = models.ForeignKey(Question, on_delete = models.CASCADE)
  19. choice_text = models.CharField(max_length=200)
  20. votes = models.IntegerField(default=0)
  21.  
  22. class addresses(models.Model):
  23. # address = models.CharField(max_length=1000, blank=True, null = True)
  24. # lat = models.FloatField(blank=True, null = True)
  25. # lon = models.FloatField(blank = True, null = True)
  26. # point = models.PointField(blank = True, null = True)
  27.  
  28. # def save(self, *args, **bwargs):
  29. # if self.lat and self.lon:
  30. # self.point = geos.Point(self.lon, self.lat)
  31. #
  32. # return super(addresses, self).save(*args, **bwargs)
  33. conn = psycopg2.connect(dbname = "mydb", user = "andrey", password = "aaa111")
  34. cur = conn.cursor()
  35. cur.execute("""SELECT * from addresses""")
  36. rows = cur.fetchall()
  37. cur.close()
  38. conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement