crossplatform.ru

Здравствуйте, гость ( Вход | Регистрация )

 
Ответить в данную темуНачать новую тему
> PyQt4, PyInstaller(1.5), QSQL -проблемы переноса приложения
Andrewshkovskii
  опции профиля:
сообщение 2.9.2011, 15:03
Сообщение #1


Активный участник
***

Группа: Участник
Сообщений: 351
Регистрация: 27.12.2008
Пользователь №: 467

Спасибо сказали: 18 раз(а)




Репутация:   1  


Python 2.7.2, PyQt 4.8.4-1, PyInstaller 1.5, WinXp, база- MS SQL Server 2008.
Есть вот такой вот код:
# -*- coding: utf-8 -*-
from PyQt4 import QtGui, QtCore, QtSql

if __name__ == '__main__' :
    import sys
    app = QtGui.QApplication(sys.argv)
    codec = QtCore.QTextCodec.codecForName("UTF-8")
    QtCore.QTextCodec.setCodecForCStrings(codec)
    database = QtSql.QSqlDatabase().addDatabase('QODBC')
    database.setUserName('sa')#192.168.12.44
    database.setPassword('123123')#93.188.153.130,9999
    database.setDatabaseName("Driver={SQL Server Native Client 10.0};Server=192.168.12.44;Database=infopin;Uid=sa;Pwd=123123;")
    database.open()
    res = QtSql.QSqlQueryModel()
    res.setQuery('select tp.id , tp.name , COUNT(cust.CustomerID) as "count" , tp.date_from , tp.date_to , case tp.is_active when 1 then 1 else 0 end active, tp.min_charge , tp.user_charge , sum(ac.user_charge) sum from infopin.tarifficator.tariff_plan tp left join infopin.tarifficator.tariff_plan_type tpt on tp.type_id= tpt.id left join infopin.dbo.Customers cust on cust.TarifID=tp.id left join infopin.tarifficator.available_component ac on ac.tariff_plan_id=tp.id where tp.type_id = 1 group by tp.id, tp.name, tpt.name, tp.date_from, tp.date_to, tp.user_charge, tp.min_charge, tp.is_active', database)
    mw = QtGui.QTableView()
    mw.setModel(res)
    mw.show()
    query_result = QtSql.QSqlQuery(database)
    query_result.exec_('select tp.id , tp.name , COUNT(cust.CustomerID) as "count" , tp.date_from , tp.date_to , case tp.is_active when 1 then 1 else 0 end active, tp.min_charge , tp.user_charge , sum(ac.user_charge) sum from infopin.tarifficator.tariff_plan tp left join infopin.tarifficator.tariff_plan_type tpt on tp.type_id= tpt.id left join infopin.dbo.Customers cust on cust.TarifID=tp.id left join infopin.tarifficator.available_component ac on ac.tariff_plan_id=tp.id where tp.type_id = 1 group by tp.id, tp.name, tpt.name, tp.date_from, tp.date_to, tp.user_charge, tp.min_charge, tp.is_active')
    result = []
    r = query_result.record()
    cnt = r.count()
    while query_result.next() :
        for i in xrange(0, cnt):
            print r.fieldName(i), query_result.value(i).isNull(), query_result.value(i).isValid()
        hr = dict(((str(r.fieldName(i)), unicode(query_result.value(i).toString())) for i in xrange(0, cnt)))
        result.append(hr)
    print [str(i) for i in database.drivers()]
    driver = database.driver()
    print driver, driver.objectName(), driver.hasFeature(QtSql.QSqlDriver.LowPrecisionNumbers), driver.lastError().text()
    sys.exit(app.exec_())


На машине разработчика результат кода такой :
Цитата
id False True
name False True
count False True
date_from False True
date_to True True
active False True
min_charge True True
user_charge True True
sum False True
id False True
name False True
count False True
date_from True True
date_to True True
active False True
min_charge False True
user_charge True True
sum False True
id False True
name False True
count False True
date_from False True
date_to True True
active False True
min_charge False True
user_charge False True
sum False True
id False True
name False True
count False True
date_from False True
date_to False True
active False True
min_charge False True
user_charge False True
sum False True
['QSQLITE', 'QMYSQL3', 'QMYSQL', 'QODBC3', 'QODBC', 'QPSQL7', 'QPSQL']
<PyQt4.QtSql.QSqlDriver object at 0x00B5AF60> True



На машине клиента (winXp):
Цитата
id False True
name False True
count False True
date_from False True
date_to True True
active False True
min_charge True True
user_charge True True
sum True False
id False True
name False True
count False True
date_from True True
date_to True True
active False True
min_charge True False
user_charge True True
sum True False
id False True
name False True
count False True
date_from False True
date_to True True
active False True
min_charge True False
user_charge True False
sum True False
id False True
name False True
count False True
date_from False True
date_to False True
active False True
min_charge True False
user_charge True False
sum True False
['QSQLITE', 'QODBC3', 'QODBC']
<PyQt4.QtSql.QSqlDriver object at 0x00B31150> True


Собираю pyInstaller'ом вот так:
Цитата
@python C:/workspace/pyinstaller-1.5/pyinstaller-1.5/Makespec.py -F -X main.py
@python C:/workspace/pyinstaller-1.5/pyinstaller-1.5/Build.py main.spec

Скажу сразу - почему-то не грузяться десятичные числа. как узнать, откуда бага растет, и почему?
И как узнать, какой именно SQl-драйвер загружен сейчас?
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение

Быстрый ответОтветить в данную темуНачать новую тему
Теги
Нет тегов для показа


1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0




RSS Текстовая версия Сейчас: 29.3.2024, 2:33