postgresql

Once i activate models in django, why can't i query them directly in postgresql pgAdmin UI?

寵の児 提交于 2021-02-07 09:57:53
问题 I am very new to Django & to web programming in general. So, I apologize for the silly question. I am using django as a framework with python & I have made a connection with my database, Postgresql : DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'testdb', 'USER': 'postgres', 'PASSWORD': '****', 'HOST': 'localhost', 'PORT': '5432', } } After that I ran the python manage.py migrate command & it outputted that everything was OK. I have also created models

Once i activate models in django, why can't i query them directly in postgresql pgAdmin UI?

岁酱吖の 提交于 2021-02-07 09:57:39
问题 I am very new to Django & to web programming in general. So, I apologize for the silly question. I am using django as a framework with python & I have made a connection with my database, Postgresql : DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'testdb', 'USER': 'postgres', 'PASSWORD': '****', 'HOST': 'localhost', 'PORT': '5432', } } After that I ran the python manage.py migrate command & it outputted that everything was OK. I have also created models

How to get the id of last inserted row using preparedstatement? [duplicate]

拈花ヽ惹草 提交于 2021-02-07 09:38:55
问题 This question already has answers here : How to get a value from the last inserted row? [duplicate] (14 answers) Closed 7 years ago . I am using the following code to insert a new row to database, I need to get the id of the last inserted row but when I run the code it shows the following message: SEVERE: java.sql.SQLException: Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate() or Connection.prepareStatement(). When I use the

Sql query to get src to dest path for connecting flights

匆匆过客 提交于 2021-02-07 09:17:58
问题 I want to solve a problem where I wish to find src to dest flight path including connecting flights and if possible sort it for time required. Can I use something like listagg to aggregate intermediate flights as a string somehow. We could cap the number of connecting flights to a number and the time taken. I have this as a start right now which gives me connecting flights with cap as (select 30 time_cap , 5 connect_cap), connecting as (select f1.src src1 , f1.dest dest1 , f1.stt st1 , f1

Sql query to get src to dest path for connecting flights

早过忘川 提交于 2021-02-07 09:17:08
问题 I want to solve a problem where I wish to find src to dest flight path including connecting flights and if possible sort it for time required. Can I use something like listagg to aggregate intermediate flights as a string somehow. We could cap the number of connecting flights to a number and the time taken. I have this as a start right now which gives me connecting flights with cap as (select 30 time_cap , 5 connect_cap), connecting as (select f1.src src1 , f1.dest dest1 , f1.stt st1 , f1

Sql query to get src to dest path for connecting flights

半城伤御伤魂 提交于 2021-02-07 09:17:00
问题 I want to solve a problem where I wish to find src to dest flight path including connecting flights and if possible sort it for time required. Can I use something like listagg to aggregate intermediate flights as a string somehow. We could cap the number of connecting flights to a number and the time taken. I have this as a start right now which gives me connecting flights with cap as (select 30 time_cap , 5 connect_cap), connecting as (select f1.src src1 , f1.dest dest1 , f1.stt st1 , f1

SQL - does order of OR conditions matter?

你离开我真会死。 提交于 2021-02-07 09:13:04
问题 I have to SELECT one row which meets condition1 OR condition2 . However, condition1 is preferable. If there are two rows, where the first one meets condition1 (and does not meet condition2) and second meets condition2 (and does not meet condition1 ) then the first one should be returned. So for SQL: SELECT * FROM table WHERE col1 = 1 OR col2 = 5 LIMIT 1 Will it return the row that meets condition col1 = 1 first? Or will it return rows in random order? If it will be random then how to achieve

SQL - does order of OR conditions matter?

橙三吉。 提交于 2021-02-07 09:12:58
问题 I have to SELECT one row which meets condition1 OR condition2 . However, condition1 is preferable. If there are two rows, where the first one meets condition1 (and does not meet condition2) and second meets condition2 (and does not meet condition1 ) then the first one should be returned. So for SQL: SELECT * FROM table WHERE col1 = 1 OR col2 = 5 LIMIT 1 Will it return the row that meets condition col1 = 1 first? Or will it return rows in random order? If it will be random then how to achieve

Delete functionality with spark sql dataframe

泪湿孤枕 提交于 2021-02-07 08:47:36
问题 I have a requirement to do a load/delete specific records from postgres db for my spark application. For loading , I am using spark dataframe in the below format sqlContext.read.format("jdbc").options(Map("url" -> "postgres url", "user" -> "user" , "password" -> "xxxxxx" , "table" -> "(select * from employee where emp_id > 1000) as filtered_emp")).load() To delete the data, I am writing direct sql instead of using dataframes delete from employee where emp_id > 1000 The question is , is there

Excel to PostgreSQL using Python

↘锁芯ラ 提交于 2021-02-07 08:36:54
问题 I'm new to Python and I'm trying to export excel directly into postgreSQL without CSV files. I don't know if it's possible. I keep running into the error 'column "daily_date" is of type date but expression is of type numeric' . import psycopg2 import xlrd book = xlrd.open_workbook("pytest.xlsx") sheet = book.sheet_by_name("Source") database = psycopg2.connect (database = "RunP", user="postgres", password="", host="localhost", port="5432") cursor = database.cursor() query = """INSERT INTO