Category : postgresql

Why, when reading data from the database, I get the wrong time zone (offset)? I have next table Tests: class Test(Base): __tablename__ = ‘tests’ id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, unique=True) test_datetime = Column(DateTime(timezone=True), nullable=False, default=datetime.utcnow()) def __init__(self, test_datetime): self.test_datetime = test_datetime def __repr__(self): return f'<Test(id={self.id}, test_datetime={self.test_datetime})’ I’m trying to understand why, when writing the same ..

Read more

I am new to odoo. And I had successfully imported a copy of the dump database to PostgreSQL. After importing dump database the following error occurs. **Traceback (most recent call last): File "/opt/odoo13/odoo/odoo/addons/base/models/qweb.py", line 333, in _compiled_fn return compiled(self, append, new, options, log) File "<template>", line 1, in template_web_login_7 File "<template>", line 2, in body_call_content_5 ..

Read more

I am trying to copy a Pandas data frame as a temporary table into a local PostgreSQL database. I would like the temporary table to disappear when the connection is closed. Also, it should only be visible to the current connection to the source. An equivalent built-in function in R is copy_to() https://dplyr.tidyverse.org/reference/copy_to.html Is there ..

Read more

I was switching all my queries to parameterized query.But I dont know how I can create a query using parameterized query in LIKE or ILIKE . inputs can be multiple single quote . Like this one , " ‘ACCESS_POINT’, ‘DESKTOP’, ‘GATEWAY’, ‘IP_DESK_PHONE’, ‘IP_TV’, ‘IP_WEBCAM’, ‘LAPTOP’, ‘MAINFRAME’, ‘MINI_COMPUTER’, ‘OTHER’, ‘PRINTER’, ‘ROUTER’, ‘SCANNER’, ‘SERVER’, ‘SMARTPHONE’, ‘SWITCH’, ‘TABLET’, ..

Read more

I am trying to run concurrent prepared statements(procedure calls) via Python code to test out the concurrency in Redshift. For this I have created below files – Yaml file – which contains connection string for the cluster, with number of threads and number of queries to run run.py – python code to run multiple statements ..

Read more

I am following the documentation about SQLAlchemy connections and engines, but the issue I am experiencing does not seem to be documented anywhere. In my application, I have a class that initializes with a postgres db_engine : class FooBar(object): def __init__(self,db_engine: engine): self._db_engine: engine = db_engine Now that a db_engine is accessible in the class, ..

Read more

I am using the peewee ORM to define the following model in my models.py file: User(Model): name = CharField() settings = JSONField() class Meta: database = PostgresqlExtDatabase(‘my_db’, user=…) I am trying to do the following: import json from models import User User.create(name="Foo", settings=json.dumps({"mode": "light"})) But when I run this code, I get the following error: ..

Read more

here is my model.py, Where Customer is the one to make orders and purchase Products. class Customer(models.Model): user = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE) name = models.CharField(max_length=25, null=True) phone = models.CharField(max_length=12, null=True) def __str__(self): return self.name class Product(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) coinid = models.CharField(max_length=255, null=True) digit = models.CharField(max_length=18, null=True) ctp = models.FloatField(max_length=100, null=True) transection_id = ..

Read more