Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime
- #from django.db import models
- from django.utils import timezone
- from django.contrib.gis.db import models
- from django.contrib.gis import geos
- import psycopg2
- class Question(models.Model):
- question_text = models.CharField(max_length=120)
- pub_date = models.DateTimeField(default=timezone.now)
- class Choice(models.Model):
- question = models.ForeignKey(Question, on_delete = models.CASCADE)
- choice_text = models.CharField(max_length=200)
- votes = models.IntegerField(default=0)
- class addresses(models.Model):
- # address = models.CharField(max_length=1000, blank=True, null = True)
- # lat = models.FloatField(blank=True, null = True)
- # lon = models.FloatField(blank = True, null = True)
- # point = models.PointField(blank = True, null = True)
- # def save(self, *args, **bwargs):
- # if self.lat and self.lon:
- # self.point = geos.Point(self.lon, self.lat)
- #
- # return super(addresses, self).save(*args, **bwargs)
- conn = psycopg2.connect(dbname = "mydb", user = "andrey", password = "aaa111")
- cur = conn.cursor()
- cur.execute("""SELECT * from addresses""")
- rows = cur.fetchall()
- cur.close()
- conn.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement