Re: export sql query to excel

2018-04-16 Thread sum abiut
Thanks guys it took me a while and a lot of research, finally get it to
work.

my view.py

import pandas as pd
from django.http import HttpResponse
try:
from io import BytesIO as IO # for modern python
except ImportError:
from StringIO import StringIO as IO # for legacy python

def download_excel(request):
if "selectdate" in request.POST:
if "selectaccount" in request.POST:
selected_date = request.POST["selectdate"]
selected_acc = request.POST["selectaccount"]
if selected_date==selected_date:
if selected_acc==selected_acc:
convert=datetime.datetime.strptime(selected_date,
"%Y-%m-%d").toordinal()

engine=create_engine('mssql+pymssql://username:password@servername /db')


metadata=MetaData(connection)

fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)

rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)

stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,rate.columns.date_applied,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])

stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_applied==convert))
results=connection.execute(stmt)

sio = StringIO()
df = pd.DataFrame(data=list(results),
columns=results.keys())

dowload excel file##
excel_file = IO()
xlwriter = pd.ExcelWriter(excel_file, engine='xlsxwriter')
df.to_excel(xlwriter, 'sheetname')
xlwriter.save()
xlwriter.close()
excel_file.seek(0)

response = HttpResponse(excel_file.read(),
content_type='application/ms-excel
vnd.openxmlformats-officedocument.spreadsheetml.sheet')
# set the file name in the Content-Disposition header
response['Content-Disposition'] = 'attachment;
filename=myfile.xls'
return response











On Tue, Apr 17, 2018 at 1:40 PM, Gerardo Palazuelos Guerrero <
gerardo.palazue...@gmail.com> wrote:

> hi,
> I don´t have this github, so let me try to show you what I do.
> Sorry if I´m not applying best practices, but this is working on my side;
> I run this manually from cmd in Windows 10 (no django on this).
>
> Content of my requirements.txt:
> et-xmlfile==1.0.1
> jdcal==1.3
> openpyxl==2.5.1
> pyodbc==4.0.22
>
>
>
> This is something optional I did. I extracted my database connection from
> the simple py file:
> import pyodbc
>
> class connection:
> conn = None
>
> def get_connection(self):
> self.conn = pyodbc.connect(
> r'DRIVER={ODBC Driver 13 for SQL Server};'
> r'SERVER=;'
> r'DATABASE=;'
> r'UID=;'
> r'PWD= )
>
> return self.conn
>
>
>
> This is my routine to generate excel file:
> from mssqlconnection import connection
> import sys
> import openpyxl
> import os
> import calendar
> import time
> import datetime
> import smtplib
> import base64
>
> cursor = connection().get_connection().cursor()
>
>
> query_to_execute = """
> the SQL query goes here
> """
>
> def run_query(start_date, end_date):
>
> # executing the query, also I´m passing parameters to my query (dates)
> cursor.execute(query_to_execute, (start_date, end_date))
>
> # load columns into a list
> columns = [column[0] for column in cursor.description]
> #print(columns)
>
> dir_path = os.path.dirname(os.path.realpath(__file__))
> print("file to be saved in following directory: %s" % dir_path)
>
> os.chdir(dir_path)
> wb = openpyxl.Workbook()
> sheet = wb["Sheet"] # default sheet to be renamed
>
> new_sheet_name = "CustomSheetName"
> sheet.title = new_sheet_name
>
> rows = cursor.fetchall()
> tmpRows = 1
> tmpColumns = 0
>
> # save the columns names on first row
> for column in columns:
> tmpColumns += 1
> sheet.cell(row = tmpRows, column = tmpColumns).value = column
>
> # save rows, iterate over each and every row
> # this process is fast, for my surprise
> for row in rows:
> tmpRows += 1
> tmpColumns = 0
> for column in columns:
> tmpColumns += 1
> sheet.cell(row = tmpRows, column = tmpColumns).value = str(getattr
> (row,column))
>
> excel_file_name = "myfilenamegoeshere.xlsx"
>
> full_path = "%s\\%s" % (dir_path, excel_file_name)
>
> wb.save(excel_file_name)
> cursor.close()
>
> write_log("excel file created with the following filename: %s" %
> excel_file_name)
>
>
> After Excel file is generated, I´m sending it by email.
>
> I hopes that helps.
>
> Gerardo.
>
>
>
> --
> Gerardo Palazuelos Guerrero
>
>
> On Mon, Apr 16, 2018 at 6:50 PM, sum abiut  wrote:
>
>> Thanks Larry,
>> How to i pass my query parameter to the xlsxwriter.
>>
>> Cheers
>>
>>
>>
>> On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell 
>> wrote:
>>
>>> I use xlsxwriter and I do it like this:
>>>
>>> output = io.BytesIO()
>>> workbook = 

Re: export sql query to excel

2018-04-16 Thread Gerardo Palazuelos Guerrero
hi,
I don´t have this github, so let me try to show you what I do.
Sorry if I´m not applying best practices, but this is working on my side; I
run this manually from cmd in Windows 10 (no django on this).

Content of my requirements.txt:
et-xmlfile==1.0.1
jdcal==1.3
openpyxl==2.5.1
pyodbc==4.0.22



This is something optional I did. I extracted my database connection from
the simple py file:
import pyodbc

class connection:
conn = None

def get_connection(self):
self.conn = pyodbc.connect(
r'DRIVER={ODBC Driver 13 for SQL Server};'
r'SERVER=;'
r'DATABASE=;'
r'UID=;'
r'PWD= wrote:

> Thanks Larry,
> How to i pass my query parameter to the xlsxwriter.
>
> Cheers
>
>
>
> On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell 
> wrote:
>
>> I use xlsxwriter and I do it like this:
>>
>> output = io.BytesIO()
>> workbook = xlsxwriter.Workbook(output, {'in_memory': True})
>> # write file
>> output.seek(0)
>> response = HttpResponse(output.read(),
>> content_type='application/ms-excel')
>> response['Content-Disposition'] = "attachment; filename=%s" %
>> xls_name
>> return response
>>
>> On Mon, Apr 16, 2018 at 2:05 AM, sum abiut  wrote:
>> > my code actually worked. I thought it was going to save the excel file
>> to
>> > 'C:\excel' folder so i was looking for the file in the folder but i
>> couldn't
>> > find the excel file. The excel file was actually exported to my django
>> > project folder instead.
>> >
>> > How to i allow the end user to be able to download the file to their
>> desktop
>> > instead of exporting it to the server itself
>> >
>> >
>> >
>> > On Mon, Apr 16, 2018 at 3:27 PM, sum abiut  wrote:
>> >>
>> >> I wrote a function to export sql query to an excel file, but some how
>> the
>> >> excel file wasn't created when the function was call. appreciate any
>> >> assistances
>> >>
>> >> here is my view.py
>> >>
>> >> def download_excel(request):
>> >> if "selectdate" in request.POST:
>> >> if "selectaccount" in request.POST:
>> >> selected_date = request.POST["selectdate"]
>> >> selected_acc = request.POST["selectaccount"]
>> >> if selected_date==selected_date:
>> >> if selected_acc==selected_acc:
>> >> convert=datetime.datetime.strptime(selected_date,
>> >> "%Y-%m-%d").toordinal()
>> >>
>> >> engine=create_engine('mssql+pymssql://username:password@servername
>> /db')
>> >> connection = engine.connect()
>> >> metadata=MetaData()
>> >>
>> >> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
>> >>
>> >> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
>> >>
>> >> stmt=select([fund.columns.account_code,fund.columns.descript
>> ion,fund.columns.nat_balance,fund.columns.rate_type_home,
>> rate.columns.date_applied,rate.columns.date_entered,
>> fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
>> >>
>> >> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.
>> columns.journal_ctrl_num,fund.columns.account_code==selected
>> _acc,rate.columns.date_entered==convert))
>> >>
>> >> df = pd.read_sql(stmt,connection)
>> >>
>> >> writer = pd.ExcelWriter('C:\excel\export.xls')
>> >> df.to_excel(writer, sheet_name ='bar')
>> >> writer.save()
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an
>> > email to django-users+unsubscr...@googlegroups.com.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > Visit this group at https://groups.google.com/group/django-users.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/msgid/django-users/CAPCf-y75oSOh
>> thBTv8JjhCjEoZHy1_TC7dn%3DKwG%3D8GGqjwPA3Q%40mail.gmail.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CACwCsY5O0pfHkkXCd430fe6nO%2B0pJgedqtkXoMov
>> ropRUnqfUg%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email 

Re: export sql query to excel

2018-04-16 Thread Larry Martell
The same way you pass parameters to any view.

On Mon, Apr 16, 2018 at 8:50 PM, sum abiut  wrote:
> Thanks Larry,
> How to i pass my query parameter to the xlsxwriter.
>
> Cheers
>
>
>
> On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell 
> wrote:
>>
>> I use xlsxwriter and I do it like this:
>>
>> output = io.BytesIO()
>> workbook = xlsxwriter.Workbook(output, {'in_memory': True})
>> # write file
>> output.seek(0)
>> response = HttpResponse(output.read(),
>> content_type='application/ms-excel')
>> response['Content-Disposition'] = "attachment; filename=%s" %
>> xls_name
>> return response
>>
>> On Mon, Apr 16, 2018 at 2:05 AM, sum abiut  wrote:
>> > my code actually worked. I thought it was going to save the excel file
>> > to
>> > 'C:\excel' folder so i was looking for the file in the folder but i
>> > couldn't
>> > find the excel file. The excel file was actually exported to my django
>> > project folder instead.
>> >
>> > How to i allow the end user to be able to download the file to their
>> > desktop
>> > instead of exporting it to the server itself
>> >
>> >
>> >
>> > On Mon, Apr 16, 2018 at 3:27 PM, sum abiut  wrote:
>> >>
>> >> I wrote a function to export sql query to an excel file, but some how
>> >> the
>> >> excel file wasn't created when the function was call. appreciate any
>> >> assistances
>> >>
>> >> here is my view.py
>> >>
>> >> def download_excel(request):
>> >> if "selectdate" in request.POST:
>> >> if "selectaccount" in request.POST:
>> >> selected_date = request.POST["selectdate"]
>> >> selected_acc = request.POST["selectaccount"]
>> >> if selected_date==selected_date:
>> >> if selected_acc==selected_acc:
>> >> convert=datetime.datetime.strptime(selected_date,
>> >> "%Y-%m-%d").toordinal()
>> >>
>> >> engine=create_engine('mssql+pymssql://username:password@servername
>> >> /db')
>> >> connection = engine.connect()
>> >> metadata=MetaData()
>> >>
>> >> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
>> >>
>> >> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
>> >>
>> >>
>> >> stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,fund.columns.rate_type_home,rate.columns.date_applied,rate.columns.date_entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
>> >>
>> >>
>> >> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_entered==convert))
>> >>
>> >> df = pd.read_sql(stmt,connection)
>> >>
>> >> writer = pd.ExcelWriter('C:\excel\export.xls')
>> >> df.to_excel(writer, sheet_name ='bar')
>> >> writer.save()

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5CNHJ%2BM1AP__6g%2BqwXu1eGPmUZrcfnZJuq1xm%2BQikDtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: export sql query to excel

2018-04-16 Thread Larry Martell
I was just giving you an example of how I do it. You do not need to
use xlsxwriter - you can use anything you want to generate your xls
files. The key to allowing the user to download it is returning a
HttpResponse with content_type='application/ms-excel'

On Mon, Apr 16, 2018 at 6:26 PM, sum abiut  wrote:
> Thanks Larry,
> I haven't actually try xlsxwriter before so i find some difficulties
> understanding your code. Do you mind explaining the code, i will definitely
> have a read on the documentation.
>
> cheers
>
>
> On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell 
> wrote:
>>
>> I use xlsxwriter and I do it like this:
>>
>> output = io.BytesIO()
>> workbook = xlsxwriter.Workbook(output, {'in_memory': True})
>> # write file
>> output.seek(0)
>> response = HttpResponse(output.read(),
>> content_type='application/ms-excel')
>> response['Content-Disposition'] = "attachment; filename=%s" %
>> xls_name
>> return response
>>
>> On Mon, Apr 16, 2018 at 2:05 AM, sum abiut  wrote:
>> > my code actually worked. I thought it was going to save the excel file
>> > to
>> > 'C:\excel' folder so i was looking for the file in the folder but i
>> > couldn't
>> > find the excel file. The excel file was actually exported to my django
>> > project folder instead.
>> >
>> > How to i allow the end user to be able to download the file to their
>> > desktop
>> > instead of exporting it to the server itself
>> >
>> >
>> >
>> > On Mon, Apr 16, 2018 at 3:27 PM, sum abiut  wrote:
>> >>
>> >> I wrote a function to export sql query to an excel file, but some how
>> >> the
>> >> excel file wasn't created when the function was call. appreciate any
>> >> assistances
>> >>
>> >> here is my view.py
>> >>
>> >> def download_excel(request):
>> >> if "selectdate" in request.POST:
>> >> if "selectaccount" in request.POST:
>> >> selected_date = request.POST["selectdate"]
>> >> selected_acc = request.POST["selectaccount"]
>> >> if selected_date==selected_date:
>> >> if selected_acc==selected_acc:
>> >> convert=datetime.datetime.strptime(selected_date,
>> >> "%Y-%m-%d").toordinal()
>> >>
>> >> engine=create_engine('mssql+pymssql://username:password@servername
>> >> /db')
>> >> connection = engine.connect()
>> >> metadata=MetaData()
>> >>
>> >> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
>> >>
>> >> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
>> >>
>> >>
>> >> stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,fund.columns.rate_type_home,rate.columns.date_applied,rate.columns.date_entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
>> >>
>> >>
>> >> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_entered==convert))
>> >>
>> >> df = pd.read_sql(stmt,connection)
>> >>
>> >> writer = pd.ExcelWriter('C:\excel\export.xls')
>> >> df.to_excel(writer, sheet_name ='bar')
>> >> writer.save()

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY61bx7_oFFq4%3D7ShNJc3G-Em21DDD_b%3DwdJOxeK9wa-yg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Admin search field for inlines in foreign key relationships

2018-04-16 Thread Raphaël
Hi,

I have two models, say Boxes and Widgets, using a Foreign Key field on 
Widgets to link them to Boxes.

A couple years ago, when I first started this project, I used this 
StackOverflow post 

 to 
create a multi-select input so an administrator could easily add Widgets to 
Boxes.

The Widgets, however, are synchronized from an external provider. Recently 
we suddenly got ~60,000 Widgets added to the database, which makes 
the ModelMultipleChoiceField unusable, but it would still be ideal to be 
able to quickly add Widgets from the Box edit page.

What's the recommended way to do this? I was hoping that in the years 
since, perhaps a "search" field, similar to the one provided 
with raw_id_fields would have been added to the Admin's "Inline" system 
(hit search, find the record, have it added to the inlines before saving), 
but I haven't come across anything in my searches. Is there anything like 
that on the horizon, or are there any other simple ways to get this done? 
Or should we stick to searching through the Widgets and changing their 
boxes individually?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2e2a84e3-5dc3-4730-b155-5a3e1a7e7b3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: export sql query to excel

2018-04-16 Thread sum abiut
Thanks Larry,
How to i pass my query parameter to the xlsxwriter.

Cheers



On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell 
wrote:

> I use xlsxwriter and I do it like this:
>
> output = io.BytesIO()
> workbook = xlsxwriter.Workbook(output, {'in_memory': True})
> # write file
> output.seek(0)
> response = HttpResponse(output.read(),
> content_type='application/ms-excel')
> response['Content-Disposition'] = "attachment; filename=%s" %
> xls_name
> return response
>
> On Mon, Apr 16, 2018 at 2:05 AM, sum abiut  wrote:
> > my code actually worked. I thought it was going to save the excel file to
> > 'C:\excel' folder so i was looking for the file in the folder but i
> couldn't
> > find the excel file. The excel file was actually exported to my django
> > project folder instead.
> >
> > How to i allow the end user to be able to download the file to their
> desktop
> > instead of exporting it to the server itself
> >
> >
> >
> > On Mon, Apr 16, 2018 at 3:27 PM, sum abiut  wrote:
> >>
> >> I wrote a function to export sql query to an excel file, but some how
> the
> >> excel file wasn't created when the function was call. appreciate any
> >> assistances
> >>
> >> here is my view.py
> >>
> >> def download_excel(request):
> >> if "selectdate" in request.POST:
> >> if "selectaccount" in request.POST:
> >> selected_date = request.POST["selectdate"]
> >> selected_acc = request.POST["selectaccount"]
> >> if selected_date==selected_date:
> >> if selected_acc==selected_acc:
> >> convert=datetime.datetime.strptime(selected_date,
> >> "%Y-%m-%d").toordinal()
> >>
> >> engine=create_engine('mssql+pymssql://username:password@servername
> /db')
> >> connection = engine.connect()
> >> metadata=MetaData()
> >>
> >> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
> >>
> >> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
> >>
> >> stmt=select([fund.columns.account_code,fund.columns.
> description,fund.columns.nat_balance,fund.columns.rate_
> type_home,rate.columns.date_applied,rate.columns.date_
> entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
> >>
> >> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==
> fund.columns.journal_ctrl_num,fund.columns.account_code==
> selected_acc,rate.columns.date_entered==convert))
> >>
> >> df = pd.read_sql(stmt,connection)
> >>
> >> writer = pd.ExcelWriter('C:\excel\export.xls')
> >> df.to_excel(writer, sheet_name ='bar')
> >> writer.save()
> >>
> >>
> >
> >
> >
> > --
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/django-users/CAPCf-
> y75oSOhthBTv8JjhCjEoZHy1_TC7dn%3DKwG%3D8GGqjwPA3Q%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CACwCsY5O0pfHkkXCd430fe6nO%2B0pJgedqtkXoMovropRUnqfUg%
> 40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y67FZ4p8igDdSQzyzSVdnx9UVO6aRW07UROfz2hAgeycA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: export sql query to excel

2018-04-16 Thread sum abiut
Thanks Larry,
I haven't actually try xlsxwriter before so i find some difficulties
understanding your code. Do you mind explaining the code, i will definitely
have a read on the documentation.

cheers


On Tue, Apr 17, 2018 at 1:42 AM, Larry Martell 
wrote:

> I use xlsxwriter and I do it like this:
>
> output = io.BytesIO()
> workbook = xlsxwriter.Workbook(output, {'in_memory': True})
> # write file
> output.seek(0)
> response = HttpResponse(output.read(),
> content_type='application/ms-excel')
> response['Content-Disposition'] = "attachment; filename=%s" %
> xls_name
> return response
>
> On Mon, Apr 16, 2018 at 2:05 AM, sum abiut  wrote:
> > my code actually worked. I thought it was going to save the excel file to
> > 'C:\excel' folder so i was looking for the file in the folder but i
> couldn't
> > find the excel file. The excel file was actually exported to my django
> > project folder instead.
> >
> > How to i allow the end user to be able to download the file to their
> desktop
> > instead of exporting it to the server itself
> >
> >
> >
> > On Mon, Apr 16, 2018 at 3:27 PM, sum abiut  wrote:
> >>
> >> I wrote a function to export sql query to an excel file, but some how
> the
> >> excel file wasn't created when the function was call. appreciate any
> >> assistances
> >>
> >> here is my view.py
> >>
> >> def download_excel(request):
> >> if "selectdate" in request.POST:
> >> if "selectaccount" in request.POST:
> >> selected_date = request.POST["selectdate"]
> >> selected_acc = request.POST["selectaccount"]
> >> if selected_date==selected_date:
> >> if selected_acc==selected_acc:
> >> convert=datetime.datetime.strptime(selected_date,
> >> "%Y-%m-%d").toordinal()
> >>
> >> engine=create_engine('mssql+pymssql://username:password@servername
> /db')
> >> connection = engine.connect()
> >> metadata=MetaData()
> >>
> >> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
> >>
> >> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
> >>
> >> stmt=select([fund.columns.account_code,fund.columns.
> description,fund.columns.nat_balance,fund.columns.rate_
> type_home,rate.columns.date_applied,rate.columns.date_
> entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
> >>
> >> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==
> fund.columns.journal_ctrl_num,fund.columns.account_code==
> selected_acc,rate.columns.date_entered==convert))
> >>
> >> df = pd.read_sql(stmt,connection)
> >>
> >> writer = pd.ExcelWriter('C:\excel\export.xls')
> >> df.to_excel(writer, sheet_name ='bar')
> >> writer.save()
> >>
> >>
> >
> >
> >
> > --
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to django-users+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-users@googlegroups.com.
> > Visit this group at https://groups.google.com/group/django-users.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/django-users/CAPCf-
> y75oSOhthBTv8JjhCjEoZHy1_TC7dn%3DKwG%3D8GGqjwPA3Q%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CACwCsY5O0pfHkkXCd430fe6nO%2B0pJgedqtkXoMovropRUnqfUg%
> 40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y5iFV_drWs9umJ05o8PCo9i9V_vF%3DXwqWx7woTQOq5L8A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need Help With integrating Python Scripts with Django Frame Work

2018-04-16 Thread jacob duyon
I'm not sure how many users you have for this, but it's best practice to
use an asynchronous task queue (like Celery) to run the actual powerpoint
creation code. If you simply run the script inside the view it will block
the response from happening. You create a celery task (which in your case
would have the powerpoint code), and the view will add the task to the
queue.

Celery requires a message broker, like RabbitMQ or Redis in order to use
it. They are both simple to setup and work well. The docs are pretty good
too.

On Mon, Apr 16, 2018 at 4:06 PM, Matthew Pava  wrote:

> Add a new view that returns the files.  Connect the “Download” button to
> the URL to that view.
>
> Your view should return an HttpResponse object.  For instance, I use this
> for the user to download PDF versions of forms:
>
>
>
> response = HttpResponse(pdf_contents, content_type='application/pdf')
> response['Content-Disposition'] = "%sfilename=%s" % ('attachment; ' if 
> download
> else '', filename)
> return response
>
>
>
> For pptx, your content_type would be:
>
> '.pptx': 
> 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
>
>
>
>
>
> *From:* django-users@googlegroups.com [mailto:django-users@
> googlegroups.com] *On Behalf Of *Balu Nanduri
> *Sent:* Monday, April 16, 2018 2:48 PM
> *To:* Django users
> *Subject:* Need Help With integrating Python Scripts with Django Frame
> Work
>
>
>
> Hi,
>
>  I am working on a project where I have to communicate with
> Tableau server and generate pptx with the images downloaded. I have a
> working script to do this piece, currently the script generates pptx and
> stores it to my local filesystem.
>
>
>
> Now I would like to create a web page which would accept necessary input
> from users and should trigger the script which generates pptx and then
> downloads the files to the user's browser.
>
>
>
> I had set up DJANGO environment of the same but not getting how to call
> this script from the web page so, could anyone help me out with a overview
> on how can I call my working script on click of a button and download the
> files generated by the script.
>
>
>
> Thanks & Regards
>
> Balu
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b5471890-0cd8-4ee7-a7c5-c43840590a4d%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/02eb6190ff484840b8729f146bb3e166%40ISS1.ISS.LOCAL
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJsZ3R4qhfS8zHOHFrZkpWeags606hqoVeM-0qgHpbMM6%2BKrGw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: Need Help With integrating Python Scripts with Django Frame Work

2018-04-16 Thread Matthew Pava
Add a new view that returns the files.  Connect the “Download” button to the 
URL to that view.
Your view should return an HttpResponse object.  For instance, I use this for 
the user to download PDF versions of forms:

response = HttpResponse(pdf_contents, content_type='application/pdf')
response['Content-Disposition'] = "%sfilename=%s" % ('attachment; ' if download 
else '', filename)
return response

For pptx, your content_type would be:

'.pptx': 
'application/vnd.openxmlformats-officedocument.presentationml.presentation',


From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of Balu Nanduri
Sent: Monday, April 16, 2018 2:48 PM
To: Django users
Subject: Need Help With integrating Python Scripts with Django Frame Work

Hi,
 I am working on a project where I have to communicate with Tableau 
server and generate pptx with the images downloaded. I have a working script to 
do this piece, currently the script generates pptx and stores it to my local 
filesystem.

Now I would like to create a web page which would accept necessary input from 
users and should trigger the script which generates pptx and then downloads the 
files to the user's browser.

I had set up DJANGO environment of the same but not getting how to call this 
script from the web page so, could anyone help me out with a overview on how 
can I call my working script on click of a button and download the files 
generated by the script.

Thanks & Regards
Balu
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
django-users+unsubscr...@googlegroups.com.
To post to this group, send email to 
django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5471890-0cd8-4ee7-a7c5-c43840590a4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/02eb6190ff484840b8729f146bb3e166%40ISS1.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.


Re: Need Help With integrating Python Scripts with Django Frame Work

2018-04-16 Thread Larry Martell
Use ajax, e.g.:
https://stackoverflow.com/questions/30456958/python-script-called-by-ajax-executed-by-django-server

On Mon, Apr 16, 2018 at 3:48 PM, Balu Nanduri  wrote:
> Hi,
>  I am working on a project where I have to communicate with Tableau
> server and generate pptx with the images downloaded. I have a working script
> to do this piece, currently the script generates pptx and stores it to my
> local filesystem.
>
> Now I would like to create a web page which would accept necessary input
> from users and should trigger the script which generates pptx and then
> downloads the files to the user's browser.
>
> I had set up DJANGO environment of the same but not getting how to call this
> script from the web page so, could anyone help me out with a overview on how
> can I call my working script on click of a button and download the files
> generated by the script.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4y2AKtOqBzG0cbzZeD63YrmVHCWorF1eJzd3E7T25y%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Need Help With integrating Python Scripts with Django Frame Work

2018-04-16 Thread Balu Nanduri
Hi,
 I am working on a project where I have to communicate with Tableau 
server and generate pptx with the images downloaded. I have a working 
script to do this piece, currently the script generates pptx and stores it 
to my local filesystem.

Now I would like to create a web page which would accept necessary input 
from users and should trigger the script which generates pptx and then 
downloads the files to the user's browser.

I had set up DJANGO environment of the same but not getting how to call 
this script from the web page so, could anyone help me out with a overview 
on how can I call my working script on click of a button and download the 
files generated by the script.

Thanks & Regards
Balu

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5471890-0cd8-4ee7-a7c5-c43840590a4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Help with Channels 2.x and Celery 4.x

2018-04-16 Thread Sergio Lopez
Hi!! I need a basic example of a program with channels 2.x (Django 2.x) 
that when it fulfills a condition, it calls a task celery 4.x and updates 
its status in a message in the html. (for 
example https://vincenttide.com/blog/1/django-channels-and-celery-example/)

But i have the following error in consumer.py in "def mensaje": *raise 
ValueError("No handler for message type %s" % message["type"]):*


Mi code in *consumers.py*:


from channels.generic.websocket import AsyncJsonWebsocketConsumerfrom .tasks 
import PruebaCeleryclass Consumer(AsyncJsonWebsocketConsumer):
async def connect(self):
print(self.channel_name)
await self.accept()
print("[BACK]:Cliente conectado")

async def disconnect(self, close_code):
return None

async def receive_json(self, contenido):

try:
if True:
print("[BACK]:Datos recividos",contenido)
await self.mensaje(contenido)
except:
pass

async def mensaje(self, contenido):
print("[BACK]:Si se cumple la condicion se envia mensaje")
print(contenido["Clave_Tipo_Filtro"])
TipoFiltro = contenido["Clave_Tipo_Filtro"]
if TipoFiltro == "Filtro_Paso_Bajo":
print("dentro")
mensaje = PruebaCelery.delay(self.channel_name)
print("Here")
print ("hola %s" %str(mensaje["text"]))
print("Out")
print ("Task ID: %s" %mensaje)
await self.send("Task ID: %s" %str(mensaje))
await self.send("se ha ejecutado celery")
else:
print("no entra")

return None

Mi code in *tasks.py*:

#De celery
from Filtros.celery import app
import json
from channels.layers import get_channel_layer
from asgiref.sync import AsyncToSync


@app.task
def PruebaCelery(channel_name):
# responder al cliente
channel_layer = get_channel_layer()
AsyncToSync(channel_layer.send)(
channel_name,
{"type": "Test",
 "text": json.dumps("Hi im celery"),
 })


Mi code in *html*: *how could I print "hi im celery" in the html?*



































Re: Django 2.0.2, Channels 2.0.2 and Celery 4.1 Issue

2018-04-16 Thread Sergio Lopez
Plese, Can you send us a basic example of celery 4 and channels 2?

El viernes, 2 de marzo de 2018, 19:36:08 (UTC+1), G Broten escribió:
>
> Hi All:
>  I'm migrating a small application from Django 1.x/Channels 1.x to Django 
> 2.0.2 and Channels 2.0. I've run into an issue whose cause I'm trying to 
> determine. It could be due to a failure on my part to correctly implement 
> the channel_layer or it could be due to an
> incompatibility with Celery 4.1. The basics are:
> - Run a periodic Celery task
> - Use the channel_layer to perform a group_send
> - Have the consumer receive the group_send event and push a json  message 
> over the socket
>
> Show below is my simple consumer.py module:
> class mstatusMessage(AsyncJsonWebsocketConsumer):
>
> # WebSocket event handlers
>
> async def connect(self):
> """
> Called when the websocket is handshaking as part of initial 
> connection.
> """
> logging.info("### Connected ###")
> # Accept the connection
> await self.accept()
>
> # Add to the group so they get messages
> await self.channel_layer.group_add(
> settings.CHANNEL_GROUP,
> self.channel_name,
> )
>
> async def disconnect(self, code):
> """
> Called when the WebSocket closes for any reason.
> """
> # Remove them from the group
> await self.channel_layer.group_discard(
> settings.CHANNEL_GROUP,
> self.channel_name,
> )
>
> # Handlers for messages sent over the channel layer
>
> # These helper methods are named by the types we send - so epics.join 
> becomes epics_join
> async def epics_message(self, event):
> """
> Called when the Celery task queries Epics.
> """
> logging.error("### Received Msg ###")
> # Send a message down to the client
> await self.send_json(
> {
> "text": event["message"],
> },
> )
>
> The routing is simple:
> application = ProtocolTypeRouter({
> "websocket":  mstatusMessage
> })
>
> The Celery task is as follows:
> @shared_task
> def updateData(param):
>
> logger.error('# updateData #')
>
> # # Get an instance of the channel layer for
> # # inter task communications
> channel_layer = get_channel_layer()
>
> channel_layer.group_send(
> settings.CHANNEL_GROUP,
> {"type": "epics.message", "text": "Hello World"},
> )
>
> The results are promising as the websocket connect opens successfully and 
> the Celery task run as show by the debugging output given below:
> 127.0.0.1:59818 - - [02/Mar/2018:09:32:11] "GET /" 200 100639
> 127.0.0.1:59844 - - [02/Mar/2018:09:32:12] "WSCONNECTING /epics/" - -
> 2018-03-02 09:32:12,280 INFO ### Connected ###
> 127.0.0.1:59844 - - [02/Mar/2018:09:32:12] "WSCONNECT /epics/" - -
> [2018-03-02 09:32:12,312: ERROR/ForkPoolWorker-2] 
> mstatus.tasks.updateData[8d329e61-]: # updateData #
> [2018-03-02 09:32:13,310: ERROR/ForkPoolWorker-2] 
> mstatus.tasks.updateData[786f51a6-]: # updateData #
>
> BUT ... although the Celery task runs the consumer never 
> receives a message via the channel layer. This could be due to an
> implementation error or, maybe, a compatibility issue. The application 
> doesn't crash but the following warning is issued:
>
> [2018-03-02 09:32:02,105: WARNING/ForkPoolWorker-2] 
> /mstatus/mstatus/tasks.py:33: RuntimeWarning: coroutine 
> 'RedisChannelLayer.group_send' was never awaited
>   {"type": "epics.message", "text": "Hello World"},
>
> This warning appears related to the Python asyncio functionality. Under 
> the Celery task module, the channel_layer.group_send
> doesn't use the await directive as it's inclusion hangs the Celery task. 
> Changing the Celery task to:
> async def updateData(param):
>
> logger.error('# updateData #')
>
> # # Get an instance of the channel layer for
> # # inter task communications
> channel_layer = get_channel_layer()
>
> await channel_layer.group_send(
> settings.CHANNEL_GROUP,
> {"type": "epics.message", "text": "Hello World"},
> )
>
> This results in the following runtime warning and the Celery task fails to 
> run (the debug message is never printed) :
>
> [2018-03-02 09:45:19,804: WARNING/ForkPoolWorker-2] 
> /home/broteng/.pyenv/versions/3.6.3/envs/djchannels2/lib/python3.6/site-packages/billiard/pool.py:358:
>  
> RuntimeWarning: coroutine 'updateData' was never awaited
>   result = (True, prepare_result(fun(*args, **kwargs)))
>
> I'm sure these warnings are understood by someone who can provide guidance 
> with respect to a solution.
>
> Thanks,
>
> G Broten
>
> Reference:
>
> The application has be tried under two OS versions:
> CentOS 7.4
> Alpine Linux 3.7
>
> A partial pip list of the significant packages:
> asgi-redis (1.4.3)
> asgiref (2.1.6)
> async-timeout (2.0.0)

Access form data of POST method in table in Django

2018-04-16 Thread shawnmhy


currently I am working with Django

In template, I combined table and form and thus the code looks like this:


{% csrf_token %}

  
  
  ID
  NAME
  LOWER_BOUND
  UPPER_BOUND
  GENE_REACTION_RULE
  SUBSYSTEM
  
  
  
  {% for object in reactioninfo %}
  
  {{ 
 object.id }}
  {{ object.name }}
  {{ object.lower_bound }}
  {{ object.upper_bound }}
  {{ object.gene_reaction_rule }}
  {{ object.subsystem }}
  
  {% endfor %}
  

  Generate 
Graph
  


And in views.py, the code looks like this:


class MetaboliteDetail(FormMixin, generic.DetailView):
model = Metabolites
template_name = 'Recon/metabolite_detail.html'
def get_context_data(self, **kwargs):
pk = self.kwargs.get(self.pk_url_kwarg, None)
context = super(MetaboliteDetail, self).get_context_data(**kwargs)
context['reactions'] = Reactionsmeta.objects.all()
context['reactioninfo'] = Reactions.objects.filter(metabolites__contains=pk)
return context
def generate(self, request):

checklist = request.POST.getlist('checkbox')
btnval = request.POST.get('btnDelete')
if checklist and btnval == 'btnDelete':
   context = dict(result=checklist)
   return render(request, "Recon/combinegraph.html", context)
elif btnval == 'btnDelete':
 context = dict(result=checklist)
 return render(request, "Recon/combinegraph.html", context)
else:
 context = dict(result=checklist)
 return render(request, "Recon/combinegraph.html", context)


However, when I finished this and click on the Generate button, the url is 
actually not changed and the the page appears HTTP405 error.

What is going wrong and how can I fix this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/296ecfa9-ba1d-462a-ad26-c2d323aa0939%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Postgrid Nexval

2018-04-16 Thread LucyGeo
Como reordenar sequencia nextval no postgrid? Deletei um dado da tabela, e 
a sequencia ficou desordenada. Como ordenar? Usando a mesma função do 
oracle?Aguardo retorno. Muito obrigada!!!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0175f731-fa12-4636-8cce-5d3bd870711f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: export sql query to excel

2018-04-16 Thread Larry Martell
I use xlsxwriter and I do it like this:

output = io.BytesIO()
workbook = xlsxwriter.Workbook(output, {'in_memory': True})
# write file
output.seek(0)
response = HttpResponse(output.read(),
content_type='application/ms-excel')
response['Content-Disposition'] = "attachment; filename=%s" % xls_name
return response

On Mon, Apr 16, 2018 at 2:05 AM, sum abiut  wrote:
> my code actually worked. I thought it was going to save the excel file to
> 'C:\excel' folder so i was looking for the file in the folder but i couldn't
> find the excel file. The excel file was actually exported to my django
> project folder instead.
>
> How to i allow the end user to be able to download the file to their desktop
> instead of exporting it to the server itself
>
>
>
> On Mon, Apr 16, 2018 at 3:27 PM, sum abiut  wrote:
>>
>> I wrote a function to export sql query to an excel file, but some how the
>> excel file wasn't created when the function was call. appreciate any
>> assistances
>>
>> here is my view.py
>>
>> def download_excel(request):
>> if "selectdate" in request.POST:
>> if "selectaccount" in request.POST:
>> selected_date = request.POST["selectdate"]
>> selected_acc = request.POST["selectaccount"]
>> if selected_date==selected_date:
>> if selected_acc==selected_acc:
>> convert=datetime.datetime.strptime(selected_date,
>> "%Y-%m-%d").toordinal()
>>
>> engine=create_engine('mssql+pymssql://username:password@servername /db')
>> connection = engine.connect()
>> metadata=MetaData()
>>
>> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
>>
>> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
>>
>> stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,fund.columns.rate_type_home,rate.columns.date_applied,rate.columns.date_entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
>>
>> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_entered==convert))
>>
>> df = pd.read_sql(stmt,connection)
>>
>> writer = pd.ExcelWriter('C:\excel\export.xls')
>> df.to_excel(writer, sheet_name ='bar')
>> writer.save()
>>
>>
>
>
>
> --
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPCf-y75oSOhthBTv8JjhCjEoZHy1_TC7dn%3DKwG%3D8GGqjwPA3Q%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY5O0pfHkkXCd430fe6nO%2B0pJgedqtkXoMovropRUnqfUg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot Access Django Admin

2018-04-16 Thread Álmos Kovács
Please also check in the settings.py that admin is in your apps list.

2018-04-16 13:50 GMT+02:00 Chasan KIOUTSOUK MOUSTAFA :

> Also make sure, you have the following configuration on *urls.py*
>
> *from django.contrib import admin
> from django.urls import path, include
>
> urlpatterns = [
> path('admin/', admin.site.urls),
> ]*
>
>
>
> On Mon, Apr 16, 2018 at 2:48 PM, Chasan KIOUTSOUK MOUSTAFA <
> chas...@gmail.com> wrote:
>
>> Try this one with trailing slash /admin/
>>
>> It should work.
>>
>> On Mon, Apr 16, 2018 at 2:44 PM, David Corcoran <
>> david.corco...@batipi.com> wrote:
>>
>>> I'm trying to locate the Django Admin access. I've tried these two URL
>>> configs:
>>>
>>> /admin
>>>
>>> /adminlogin/?next=/admin
>>>
>>> The response returned at these pages is "DoesNotExist".
>>>
>>>
>>> Is there a specific folder (part of code), that I could check for these
>>> details?  I'm wondering if perhaps this was not set-up during
>>> developmentif that is the case due to the response, any feedback on
>>> where to activate this part of the Django framework in app would be
>>> appreciated.
>>>
>>> Note: need to reactivate some users within app (due to issue/limitation
>>> with API connected), and was hoping to remove the old redundant profile
>>> from the Django Admin.
>>>
>>> Thanks,
>>> David
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/django-users/627873d8-2f3c-4328-abd2-6be142bc009f%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Kind Regards.
>> --
>> Chasan KIOUTSOUK MOUSTAFA,
>> Freelance Software Engineer
>> www.chasank.com
>> --
>>
>
>
>
> --
> Kind Regards.
> --
> Chasan KIOUTSOUK MOUSTAFA,
> Freelance Software Engineer
> www.chasank.com
> --
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAOhBaNBkWDYjc4Z8QC0C21SD9jxPN
> z%3Dr2qzfVxtKQOmZpd%3D-Hg%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADFq4vXWc%2BWBdM_rOgrZmoYLzGLgR79_ZqnbHJpAXcWud6rkQg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Verify Emails

2018-04-16 Thread Hanne Moa
If you do your own email-sending code you can break off the sending after
the server sends "RCPT', that'll work regardless.

On 7 April 2018 at 14:27, 'Anthony Flury' via Django users <
django-users@googlegroups.com> wrote:

> why not use an email validator provided by Django ?
>
> https://docs.djangoproject.com/en/2.0/ref/validators/#emailvalidator
>
> The problem with the pypi module is that to validate that an email exists
> it simply looks for server in DNS (which is slightly better than the Django
> validator), but that doesn't mean that the :
>
>  * Email server will accept emails from you - or your service
>  * or that the user exists on that server ( even if the server exists).
>
> The only real way to validate that an email server is entirely valid is to
> send an email to it, asking for a reply. Email parsing will only go so far.
>
> In theory there is a defined protocol to allow clients to  query email
> servers for is valid email addresses - but most servers are set to ignore
> those requests - for obvious reasons.
>
>
> --
> Anthony Flury
> email : *anthony.fl...@btinternet.com*
> Twitter : *@TonyFlury *
>
> On 07/04/18 08:31, Samuel Muiruri wrote:
>
>> There's a python package for validating emails exists "validate_emails"
>> https://pypi.python.org/pypi/validate_email think it would be useful to
>> include it's features inside django so you can parse if emails exists
>> before sending so you only send emails to those emails that *do *exists and
>> also use it to get back those that don't so you can remove them from your
>> list like dummy emails provided to your subscription page.
>>
>> --
>> Best Regards,
>> Samuel Muiruri.
>> Student in Machine Learning & a veteran web developer.
>>
>> > =link_campaign=sig-email_content=webmail_term=icon>
>>  Virus-free. www.avast.com > il?utm_medium=email_source=link_campaign=sig-email&
>> utm_content=webmail_term=link>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com > django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAJZFZXqyb9LQEmU_DHy1QToA6y1tmq3vwDBq28X%3D
>> LYDxZgdstw%40mail.gmail.com > sgid/django-users/CAJZFZXqyb9LQEmU_DHy1QToA6y1tmq3vwDBq28X%3
>> DLYDxZgdstw%40mail.gmail.com?utm_medium=email_source=footer>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/b2ad280e-fac2-f95f-d860-194a3046e6c8%40btinternet.com.
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACQ%3DrrerKw57kNSHnG77CDg7L%2B1NzyiDCkv1yPWOHDkW%2B8bqTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot Access Django Admin

2018-04-16 Thread Chasan KIOUTSOUK MOUSTAFA
Also make sure, you have the following configuration on *urls.py*

*from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
]*



On Mon, Apr 16, 2018 at 2:48 PM, Chasan KIOUTSOUK MOUSTAFA <
chas...@gmail.com> wrote:

> Try this one with trailing slash /admin/
>
> It should work.
>
> On Mon, Apr 16, 2018 at 2:44 PM, David Corcoran  > wrote:
>
>> I'm trying to locate the Django Admin access. I've tried these two URL
>> configs:
>>
>> /admin
>>
>> /adminlogin/?next=/admin
>>
>> The response returned at these pages is "DoesNotExist".
>>
>>
>> Is there a specific folder (part of code), that I could check for these
>> details?  I'm wondering if perhaps this was not set-up during
>> developmentif that is the case due to the response, any feedback on
>> where to activate this part of the Django framework in app would be
>> appreciated.
>>
>> Note: need to reactivate some users within app (due to issue/limitation
>> with API connected), and was hoping to remove the old redundant profile
>> from the Django Admin.
>>
>> Thanks,
>> David
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/627873d8-2f3c-4328-abd2-6be142bc009f%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Kind Regards.
> --
> Chasan KIOUTSOUK MOUSTAFA,
> Freelance Software Engineer
> www.chasank.com
> --
>



-- 
Kind Regards.
--
Chasan KIOUTSOUK MOUSTAFA,
Freelance Software Engineer
www.chasank.com
--

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOhBaNBkWDYjc4Z8QC0C21SD9jxPNz%3Dr2qzfVxtKQOmZpd%3D-Hg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Cannot Access Django Admin

2018-04-16 Thread Chasan KIOUTSOUK MOUSTAFA
Try this one with trailing slash /admin/

It should work.

On Mon, Apr 16, 2018 at 2:44 PM, David Corcoran 
wrote:

> I'm trying to locate the Django Admin access. I've tried these two URL
> configs:
>
> /admin
>
> /adminlogin/?next=/admin
>
> The response returned at these pages is "DoesNotExist".
>
>
> Is there a specific folder (part of code), that I could check for these
> details?  I'm wondering if perhaps this was not set-up during
> developmentif that is the case due to the response, any feedback on
> where to activate this part of the Django framework in app would be
> appreciated.
>
> Note: need to reactivate some users within app (due to issue/limitation
> with API connected), and was hoping to remove the old redundant profile
> from the Django Admin.
>
> Thanks,
> David
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/627873d8-2f3c-4328-abd2-6be142bc009f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Kind Regards.
--
Chasan KIOUTSOUK MOUSTAFA,
Freelance Software Engineer
www.chasank.com
--

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOhBaNDK1z9TKgQdhL3Gx%3DTjXD8Tc7cZfPzC%3DEuYmx3tP-EEEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Cannot Access Django Admin

2018-04-16 Thread David Corcoran
I'm trying to locate the Django Admin access. I've tried these two URL 
configs:

/admin

/adminlogin/?next=/admin

The response returned at these pages is "DoesNotExist".  


Is there a specific folder (part of code), that I could check for these 
details?  I'm wondering if perhaps this was not set-up during 
developmentif that is the case due to the response, any feedback on 
where to activate this part of the Django framework in app would be 
appreciated.

Note: need to reactivate some users within app (due to issue/limitation 
with API connected), and was hoping to remove the old redundant profile 
from the Django Admin.  

Thanks,
David

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/627873d8-2f3c-4328-abd2-6be142bc009f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django y Python

2018-04-16 Thread Vijay Khemlani
No es necesario usar anaconda para instalar Django

Puedes usar Django 1.5 en adelante con Python 3, pero lo ideal es usar la
última versión (2.0.4)

On Sun, Apr 15, 2018 at 8:38 PM, Marcelo Giorno 
wrote:

> Soy nuevo en todo esto.
> Instale Anaconda.
> Tengo Python 3,6
> La consulta es puedo instalarme cualquier version de DJANGO?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/1bb5fde2-d427-4424-9dfd-0e929d211d37%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei3jTU%2BzdX2FqVYufc0%2BpoPZgPPUCO0QuT9yx8A26ObTow%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ARGPARSE ERROR

2018-04-16 Thread Aditya Singh
You need to download the latest version of django rest framework same as
the version specified. If you need help on the commands let me know mate.
Give it a shot it should help.
Kind Regards,
Aditya


On Mon, Apr 16, 2018, 3:57 PM Ank  wrote:

> HI all ,
>
> Installed Python 3.5 and still getting an error
>
> django-rest-swagger 2.1.2 has requirement djangorestframework>=3.5.4, but
> you'll have djangorestframework 3.5.3 which is incompatible.
>
>
> Any pointers to solve this
>
> Thanks in advance
>
> best
> Ankush
>
> On Friday, April 13, 2018 at 11:07:58 AM UTC+2, Michal Petrucha wrote:
>>
>> On Thu, Apr 12, 2018 at 07:58:08PM +, Ankush Sharma wrote:
>> > Hi Babatunde ,
>> > I installed other listed tools ! Here the main concern im talking about
>> is
>> > Argsparse -
>> > the Progressbar2 3.6.2 requires argparse, which is not installed.
>> > Thanks in advance
>> > Ank
>>
>> What version of Python are you running this on? Either it's a very old
>> one (2.6, 3.1), which would be unsupported by pretty much any
>> reasonably recent Python package, or your Python environment is messed
>> up somehow, and it lacks a part of the standard library. If the former
>> is the case, you need to migrate to a newer Python; if the latter,
>> then you need to fix your Python installation, and make sure that it
>> includes the entire standard library.
>>
>> Good luck,
>>
>> Michal
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/65019800-10a1-40bb-98e0-a22a74cc6ac5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEPfumhWmqc4RMxeODHJX2DSacMox61sqhtnxdik5%2Bv7fCqh2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ARGPARSE ERROR

2018-04-16 Thread Ank
HI all , 

Installed Python 3.5 and still getting an error

django-rest-swagger 2.1.2 has requirement djangorestframework>=3.5.4, but 
you'll have djangorestframework 3.5.3 which is incompatible.


Any pointers to solve this

Thanks in advance 

best 
Ankush

On Friday, April 13, 2018 at 11:07:58 AM UTC+2, Michal Petrucha wrote:
>
> On Thu, Apr 12, 2018 at 07:58:08PM +, Ankush Sharma wrote: 
> > Hi Babatunde , 
> > I installed other listed tools ! Here the main concern im talking about 
> is 
> > Argsparse - 
> > the Progressbar2 3.6.2 requires argparse, which is not installed. 
> > Thanks in advance 
> > Ank 
>
> What version of Python are you running this on? Either it's a very old 
> one (2.6, 3.1), which would be unsupported by pretty much any 
> reasonably recent Python package, or your Python environment is messed 
> up somehow, and it lacks a part of the standard library. If the former 
> is the case, you need to migrate to a newer Python; if the latter, 
> then you need to fix your Python installation, and make sure that it 
> includes the entire standard library. 
>
> Good luck, 
>
> Michal 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/65019800-10a1-40bb-98e0-a22a74cc6ac5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: CreateView autoset field

2018-04-16 Thread Samuel Muiruri
did you make the migration, also note it's the default if a new item is
created with the field blank.

On Sat, Apr 14, 2018 at 9:52 PM, DYAA CHBIB  wrote:

> I did the same, but it does not displayed in the field ! Any advice?
> Thanks
>
> 2018-04-14 16:02 GMT+02:00 'Ferdinand Rohlfing' via Django users <
> django-users@googlegroups.com>:
>
>> Thanks for the answer, it's working like I want it to work...
>> Nice
>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/565c773c-4c09-4b98-a4e0-76bac19bab73%40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/0QrMLT33NB4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAFVSD1q7CBvFc8wPfEMRyjad0MOmk
> N1e7Ph4GBmY_48xCrFtcA%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Best Regards,

Samuel Muiruri.

Student in Machine Learning & a veteran web developer.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJZFZXo-Gn5HGqSOZdao-kehU_e7rfxH2%2BvZiO_8ciLv3W2J9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: export sql query to excel

2018-04-16 Thread sum abiut
my code actually worked. I thought it was going to save the excel file to
'C:\excel' folder so i was looking for the file in the folder but i
couldn't find the excel file. The excel file was actually exported to my
django project folder instead.

How to i allow the end user to be able to download the file to their
desktop instead of exporting it to the server itself


On Mon, Apr 16, 2018 at 3:27 PM, sum abiut  wrote:

> I wrote a function to export sql query to an excel file, but some how the
> excel file wasn't created when the function was call. appreciate any
> assistances
>
> here is my view.py
>
> def download_excel(request):
> if "selectdate" in request.POST:
> if "selectaccount" in request.POST:
> selected_date = request.POST["selectdate"]
> selected_acc = request.POST["selectaccount"]
> if selected_date==selected_date:
> if selected_acc==selected_acc:
> convert=datetime.datetime.strptime(selected_date, 
> "%Y-%m-%d").toordinal()
> 
> engine=create_engine('mssql+pymssql://username:password@servername /db')
> connection = engine.connect()
> metadata=MetaData()
> 
> fund=Table('gltrxdet',metadata,autoload=True,autoload_with=engine)
> 
> rate=Table('gltrx_all',metadata,autoload=True,autoload_with=engine)
> 
> stmt=select([fund.columns.account_code,fund.columns.description,fund.columns.nat_balance,fund.columns.rate_type_home,rate.columns.date_applied,rate.columns.date_entered,fund.columns.journal_ctrl_num,rate.columns.journal_ctrl_num])
> 
> stmt=stmt.where(and_(rate.columns.journal_ctrl_num==fund.columns.journal_ctrl_num,fund.columns.account_code==selected_acc,rate.columns.date_entered==convert))
>
> df = pd.read_sql(stmt,connection)
>
> writer = pd.ExcelWriter('C:\excel\export.xls')
> df.to_excel(writer, sheet_name ='bar')
> writer.save()
>
>
>


--

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y75oSOhthBTv8JjhCjEoZHy1_TC7dn%3DKwG%3D8GGqjwPA3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.